Skip to content

Commit fd531ef

Browse files
authored
chore(*): upgraded react example app to the latest packages
chore(*): upgraded react example app to the latest packages
2 parents cf90b5c + 08cb3f6 commit fd531ef

File tree

51 files changed

+4709
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+4709
-26
lines changed

examples/nextjs-ssr/.eslintrc.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": ["next/core-web-vitals"],
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": ["@typescript-eslint"],
5+
"rules": {
6+
"@typescript-eslint/no-explicit-any": "warn",
7+
"no-console": "off"
8+
}
9+
}

examples/nextjs-ssr/.firebaserc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"projects": {
3+
"default": "fir-ui-rework"
4+
}
5+
}

examples/nextjs-ssr/.gitignore

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# firebase
40+
.firebase
41+
42+
# typescript
43+
*.tsbuildinfo
44+
next-env.d.ts

examples/nextjs-ssr/.prettierrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": false,
5+
"printWidth": 120,
6+
"tabWidth": 2,
7+
"useTabs": false,
8+
"endOfLine": "auto"
9+
}

examples/nextjs-ssr/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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.
25.3 KB
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { getCurrentUser } from "@/lib/firebase/serverApp";
18+
import { redirect } from "next/navigation";
19+
import ForgotPasswordScreen from "./screen";
20+
21+
export default async function ForgotPasswordPage() {
22+
const { currentUser } = await getCurrentUser();
23+
24+
if (currentUser) {
25+
redirect("/");
26+
}
27+
28+
return <ForgotPasswordScreen />;
29+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
"use client";
18+
19+
import { ForgotPasswordAuthScreen } from "@invertase/firebaseui-react";
20+
import { useRouter } from "next/navigation";
21+
22+
export default function Screen() {
23+
const router = useRouter();
24+
25+
return <ForgotPasswordAuthScreen onBackToSignInClick={() => router.push("/sign-in")} />;
26+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
@import "tailwindcss";
18+
@import "@invertase/firebaseui-styles/tailwind";
19+
20+
/* @import "@invertase/firebaseui-styles/themes/dark.css"; */
21+
/* @import "@invertase/firebaseui-styles/themes/brutalist.css"; */

examples/nextjs-ssr/app/layout.tsx

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { getCurrentUser } from "@/lib/firebase/serverApp";
18+
import type { Metadata } from "next";
19+
import { Geist, Geist_Mono } from "next/font/google";
20+
21+
import { Header } from "@/lib/components/header";
22+
import { FirebaseUIProviderHoc } from "@/lib/firebase/ui";
23+
import "./globals.css";
24+
25+
const geistSans = Geist({
26+
variable: "--font-geist-sans",
27+
subsets: ["latin"],
28+
});
29+
30+
const geistMono = Geist_Mono({
31+
variable: "--font-geist-mono",
32+
subsets: ["latin"],
33+
});
34+
35+
export const metadata: Metadata = {
36+
title: "Create Next App (SSR)",
37+
description: "Generated by create next app with SSR",
38+
};
39+
40+
export default async function RootLayout({
41+
children,
42+
}: Readonly<{
43+
children: React.ReactNode;
44+
}>) {
45+
const { currentUser } = await getCurrentUser();
46+
47+
return (
48+
<html lang="en">
49+
<body className={`${geistSans.variable} ${geistMono.variable} antialiased`}>
50+
<Header currentUser={currentUser} />
51+
<FirebaseUIProviderHoc>{children}</FirebaseUIProviderHoc>
52+
</body>
53+
</html>
54+
);
55+
}

0 commit comments

Comments
 (0)