|
| 1 | +This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app) configured for **Server-Side Rendering (SSR)**. |
| 2 | + |
| 3 | +This example demonstrates how to use Firebase UI with Next.js App Router using server-side rendering. Unlike the static export version (`nextjs`), this version uses Next.js SSR capabilities including: |
| 4 | + |
| 5 | +- Server Components for initial page rendering |
| 6 | +- Server-side authentication state checking using `getCurrentUser()` from `serverApp.ts` |
| 7 | +- Server-side redirects using `redirect()` from `next/navigation` |
| 8 | + |
| 9 | +## Getting Started |
| 10 | + |
| 11 | +First, run the development server: |
| 12 | + |
| 13 | +```bash |
| 14 | +npm run dev |
| 15 | +# or |
| 16 | +yarn dev |
| 17 | +# or |
| 18 | +pnpm dev |
| 19 | +# or |
| 20 | +bun dev |
| 21 | +``` |
| 22 | + |
| 23 | +Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. |
| 24 | + |
| 25 | +You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. |
| 26 | + |
| 27 | +This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. |
| 28 | + |
| 29 | +## Differences from Static Export Version |
| 30 | + |
| 31 | +- **No `output: "export"`** in `next.config.ts` - enables SSR |
| 32 | +- **Server Components** - Pages use `async` functions and `getCurrentUser()` from `serverApp.ts` |
| 33 | +- **Server-side redirects** - Uses `redirect()` instead of client-side `useRouter().push()` |
| 34 | +- **Server-side auth checks** - Authentication state is checked on the server before rendering |
| 35 | + |
| 36 | +## Learn More |
| 37 | + |
| 38 | +To learn more about Next.js, take a look at the following resources: |
| 39 | + |
| 40 | +- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. |
| 41 | +- [Next.js Server Components](https://nextjs.org/docs/app/building-your-application/rendering/server-components) - learn about server-side rendering |
| 42 | +- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. |
| 43 | + |
| 44 | +You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! |
| 45 | + |
| 46 | +## Deploy |
| 47 | + |
| 48 | +This app can be deployed to Firebase Hosting or any Node.js hosting platform that supports Next.js SSR: |
| 49 | + |
| 50 | +```bash |
| 51 | +pnpm run deploy |
| 52 | +``` |
| 53 | + |
| 54 | +For Firebase Hosting, ensure you have configured the hosting site `fir-ui-2025-nextjs-ssr` in your Firebase project. |
0 commit comments