From c92d282d4926f15ea926daea45deb81dff4b8cbb Mon Sep 17 00:00:00 2001 From: James Hegedus Date: Sun, 24 May 2020 16:51:37 +1000 Subject: [PATCH] chore: remove older next.js ssg example --- hosting-nextjs-ssg/.tool-versions | 2 - hosting-nextjs-ssg/README.md | 56 ------------------- hosting-nextjs-ssg/next.config.js | 5 -- .../public/firebase-hosting.svg | 37 ------------ 4 files changed, 100 deletions(-) delete mode 100644 hosting-nextjs-ssg/.tool-versions delete mode 100644 hosting-nextjs-ssg/README.md delete mode 100644 hosting-nextjs-ssg/next.config.js delete mode 100644 hosting-nextjs-ssg/public/firebase-hosting.svg diff --git a/hosting-nextjs-ssg/.tool-versions b/hosting-nextjs-ssg/.tool-versions deleted file mode 100644 index 44b4903..0000000 --- a/hosting-nextjs-ssg/.tool-versions +++ /dev/null @@ -1,2 +0,0 @@ -firebase 8.1.1 -nodejs 12.16.1 diff --git a/hosting-nextjs-ssg/README.md b/hosting-nextjs-ssg/README.md deleted file mode 100644 index 19a0aaf..0000000 --- a/hosting-nextjs-ssg/README.md +++ /dev/null @@ -1,56 +0,0 @@ -
- -# Next.js Static Site Generation (SSG) on Firebase with Firebase Hosting & Firestore - -
- -Next.js recently added [Static Site Generation (SSG) support](https://nextjs.org/blog/next-9-3) with any data source as a build-time optimization for pages who's data is already known. This method avoids Server-Side Rendering for pages who's content is known at build-time. - -This example uses `next build && next export` with the data for the `/posts/[slug].js` pages pulled from Firestore at build-time to produce a static site hosting on Firebase Hosting. Noteabley, `getStaticPaths()` has the `fallback` value set to `false`, which means if there is not HTML match for the requests `/posts/:slug`, then a `404` will ocurr. - -Live example here: https://nextjs-ssg.web.app/ - -## Setup - -```shell -# install -npm install -``` - -- `firebase login` -- `firebase init` **or** select an existing project with `firebase use --add` - - create a new Web App within the project to host your site. [See instructions here](https://firebase.google.com/docs/hosting/multisites). -- update `firebase.json` with your new Apps hosting target - - replace the `hosting.site` `TODO_YOUR_WEB_APP_DEPLOY_TARGET_HERE` with your web apps value. -- Populate your Firestore database with data. This example uses the following data structure: - - posts (root collection) - - [auto-generated document ids] - - (string: text) title - - (string: text) blurb - - (string: html) content -- replace `TODO_YOUR_PROJECT_ID_HERE` in `next.config.js` with your project's ID - -## Usage - -``` -# dev -next dev -# build production -next build -# start production locally -next start -# deploy to Firebase Hosting -npm run deploy -``` - -## Note Well - -- Firestore data is not updated in realtime for these pages. It is pulled by REST API calls during the `getStaticProps()` and `getStaticPaths()` function calls on particular pages. -- Content **cannot** be updated without a full site rebuild. -- No dynamic content is rendered for `/posts/:slug` as `getStaticPaths()` `fallback` is set to `false` meaning a failure to match with an existing HTML file will `404`. - -## Advantages to SSR - -- Site is compltely hosted on the Firebase CDN so pages load as fast as can be (available in 10s of miliseconds instead of 100s/1000s). -- Simplified development. Fewer npm scripts and no shuffling of folders. -- Development mode of nextjs works much better and without caveats as with Firebase Cloud Functions SSR method. diff --git a/hosting-nextjs-ssg/next.config.js b/hosting-nextjs-ssg/next.config.js deleted file mode 100644 index bbb2f2c..0000000 --- a/hosting-nextjs-ssg/next.config.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - env: { - FIREBASE_PROJECT_ID: "TODO_YOUR_PROJECT_ID_HERE", - }, - } diff --git a/hosting-nextjs-ssg/public/firebase-hosting.svg b/hosting-nextjs-ssg/public/firebase-hosting.svg deleted file mode 100644 index 99513a8..0000000 --- a/hosting-nextjs-ssg/public/firebase-hosting.svg +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -