• Stars
    star
    419
  • Rank 103,397 (Top 3 %)
  • Language
    TypeScript
  • Created over 4 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An Next.js example repo for building authenticated pages with Firebase Authentication, cookies, and getServerSideProps

Next.js + Firebase + getServerSideProps

This project demonstrates how to implement authenticated server-side rendering with Next.js and Firebase Authentication.

Update November 19, 2020: A bug has been fixed where the Firebase tokens would expire after an hour without being refreshed. All tokens are now force refreshed every 10 minutes.

Update November 9, 2020: this repo has been updated to use the redirect functionality introduced in [email protected] . Currently you must be on the canary release of Next for this approach to work ( yarn add next@canary ).

Versions

Documentation

Full walkthrough and documentation here: Authenticated server-side rendering with Next.js and Firebase.

How to use

To run this example:

  • Clone the repo: git clone [email protected]:vriad/next-firebase-ssr.git
  • Navigate into directory: cd next-firebase-ssr
  • Install dependencies: yarn
  • Create a Firebase project if you haven't already. Make sure you go into the Authentication tab in the Console, go to "Sign-in method", and enable "Email/Password"
  • Add your Firebase client credentials to firebaseClient.ts. To get these, go to the Firebase Console > open your project > Gear Icon > Project Settings > General > Your apps > Firebase SDK Snippet > click the "Config" radio button > copy/paste.
  • Add your service account (Admin) credentials to the project. To do this, go to the Firebase Console > open your project > click the gear icon > Project Settings > Service Accounts > click Node.js > Generate new private key. Open the JSON file that downloads. Then create a copy of .env.local.example and rename it to .env.local. This is the file where you will put your secret Firebase credentials. Copy/paste the values from the private key JSON file over to the new .env.local file: privateKey becomes PRIVATE_KEY, project_id becomes PROJECT_ID, and clientEmail becomes CLIENT_EMAIL.
  • Run yarn dev
  • Go to localhost:3000

More Repositories

1

zod

TypeScript-first schema validation with static type inference
TypeScript
33,028
star
2

devii

A developer blog starter for 2021 (Next.js + React + TypeScript + Markdown + syntax highlighting)
TypeScript
496
star
3

tozod

TypeScript
140
star
4

nextjs-react-router

A demonstration of how to use React Router inside Next.js
TypeScript
132
star
5

bye-react

Command-line tool to migrate React to Preact
JavaScript
126
star
6

typejest

Test your types
TypeScript
26
star
7

normi

A zero-config normalized cache for MobX
TypeScript
20
star
8

zod-deno

TypeScript-first schema validation for Deno
TypeScript
16
star
9

trailhead

Find paths through your data in a type-safe way
TypeScript
12
star
10

nxtk

A TypeScript toolkit for Next.js
TypeScript
12
star
11

skee

Fluent schema modeling and migrations
TypeScript
8
star
12

npm-ts-starter

A project template for TypeScript npm packages
TypeScript
8
star
13

bun-workspaces

TypeScript
4
star
14

gwen

Utility-first CSS-in-JS styling library for maniacs
TypeScript
4
star
15

typesafe-api-no-graphql

A typesafe API — no GraphQL required
TypeScript
4
star
16

zod-locales

Localized error maps for Zod
3
star
17

DougNotes

Graphical dynamic knowledge repository platform
JavaScript
3
star
18

edgedb-movies

TypeScript
2
star
19

edgedb-nextjs-blog

TypeScript
2
star
20

live-typescript-monorepo

Strategies for live-updating TypeScript types in monorepos
TypeScript
1
star
21

edgedb-remix-test-2

JavaScript
1
star
22

kickdata

A scraper deployed to the Google App Engine that scrapes all soon-to-end Kickstarter projects every 10 minutes and stores relevant data in a Parse database.
Python
1
star
23

pensiv

Realtime Thoughtstreaming app with Meteor and Ionic
JavaScript
1
star
24

colinhacks

1
star
25

onepotpony

TypeScript
1
star
26

repros

TypeScript
1
star