{"id":192,"date":"2023-08-18T23:42:04","date_gmt":"2023-08-18T23:42:04","guid":{"rendered":"https:\/\/www.grizzly-hills.com\/?p=192"},"modified":"2023-08-18T23:43:18","modified_gmt":"2023-08-18T23:43:18","slug":"firebase-hosting-with-react-vite-in-2023","status":"publish","type":"post","link":"https:\/\/www.grizzly-hills.com\/index.php\/2023\/08\/18\/firebase-hosting-with-react-vite-in-2023\/","title":{"rendered":"Firebase Hosting With React &#038; Vite in 2023"},"content":{"rendered":"\n<p>Creating a starter React app, and hosting it on Firebase Hosting, is very simple. First you create the app using Vite&#8217;s React template. Then, you initialize Firebase Hosting in the project. Finally, you run it locally to develop, and deploy it to Firebase when ready for the world to see!<\/p>\n\n\n\n<p>Create a React app named <strong>my-great-app<\/strong>:<\/p>\n\n\n\n<p><code>$ npm create vite@latest my-great-app -- --template react<\/code><br><code>$ cd <code>my-great-app<\/code><\/code><br><code>$ npm install<\/code><br><code>$ npm run build<\/code><\/p>\n\n\n\n<p>Initialize Firebase Hosting:<\/p>\n\n\n\n<p><code>$ firebase init hosting<\/code><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>select account<\/li>\n\n\n\n<li>select &#8220;Use an existing project&#8221; (or create a new one if you prefer)<\/li>\n\n\n\n<li>select your project<\/li>\n\n\n\n<li>public directory should be <code>dist<\/code><\/li>\n\n\n\n<li>answer <code>y<\/code> to &#8220;Configure a single-page app)?<\/li>\n\n\n\n<li>answer <code>n<\/code> to Set up automatic builds?<\/li>\n\n\n\n<li>answer <code>n<\/code> to the question about overwriting <code>dist\/index.html<\/code><\/li>\n<\/ul>\n\n\n\n<p>Edit <code>firebase.json<\/code> and add this line:<\/p>\n\n\n\n<p><code>\"predeploy\": \"npm run build\",<\/code><\/p>\n\n\n\n<p>right after this line:<\/p>\n\n\n\n<p><code>\"public\": \"dist\",<\/code><\/p>\n\n\n\n<p>and save the file.<\/p>\n\n\n\n<p>Finally, run your app! To develop locally, run <strong>npm run dev<\/strong>, and to deploy to Firebase Hosting, run <strong>firebase deploy<\/strong><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating a starter React app, and hosting it on Firebase Hosting, is very simple. First you create the app using Vite&#8217;s React template. Then, you initialize Firebase Hosting in the project. Finally, you run it locally to develop, and deploy it to Firebase when ready for the world to see! Create a React app named &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.grizzly-hills.com\/index.php\/2023\/08\/18\/firebase-hosting-with-react-vite-in-2023\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Firebase Hosting With React &#038; Vite in 2023&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,6],"tags":[],"class_list":["post-192","post","type-post","status-publish","format-standard","hentry","category-coding","category-react"],"_links":{"self":[{"href":"https:\/\/www.grizzly-hills.com\/index.php\/wp-json\/wp\/v2\/posts\/192","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.grizzly-hills.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.grizzly-hills.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.grizzly-hills.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.grizzly-hills.com\/index.php\/wp-json\/wp\/v2\/comments?post=192"}],"version-history":[{"count":1,"href":"https:\/\/www.grizzly-hills.com\/index.php\/wp-json\/wp\/v2\/posts\/192\/revisions"}],"predecessor-version":[{"id":193,"href":"https:\/\/www.grizzly-hills.com\/index.php\/wp-json\/wp\/v2\/posts\/192\/revisions\/193"}],"wp:attachment":[{"href":"https:\/\/www.grizzly-hills.com\/index.php\/wp-json\/wp\/v2\/media?parent=192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.grizzly-hills.com\/index.php\/wp-json\/wp\/v2\/categories?post=192"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.grizzly-hills.com\/index.php\/wp-json\/wp\/v2\/tags?post=192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}