Next.js Firebase Authentication for Edge and Node.js runtimes. Use Firebase Authentication with latest Next.js features.
The starter demo is available at next-firebase-auth-edge-starter.vercel.app
You can find source code for the demo in examples/next-typescript-starter
If you're new to Firebase or Next.js, you can follow this comprehensive, step-by-step guide on integrating Firebase Authentication with Next.js using next-firebase-auth-edge library:
https://hackernoon.com/using-firebase-authentication-with-the-latest-nextjs-features
Official library documentation can be found at https://next-firebase-auth-edge-docs.vercel.app
Official firebase-admin
library relies heavily on Node.js internal crypto
library and primitives that are unavailable inside Next.js Edge Runtime.
This library aims to solve the problem of creating and verifying Custom ID Tokens using Web Crypto API available inside Edge runtimes.
next-firebase-auth-edge
is compatible with latest Next.js features, such as App Router or Server Components
To allow gradual adoption of latest Next.js features, next-firebase-auth-edge
works interchangeably with getServerSideProps and legacy Api Routes
- Supports latest Next.js features
- Zero-bundle size
-
Minimal configuration: In contrary to other libraries, you don't have to define your own API routes or update your
next.config.js
file. All heavy lifting is done by the middleware. - Secure: Uses jose for JWT validation. Signs user cookies with rotating keys to mitigate the risk of cryptanalysis attacks
Most notable features are:
- Support for domain restricted Firebase API Keys
- Removed APIs deprecated in v1.0
- Updates several advanced methods
See 1.5.x canary release for detailed API changes description
With npm
npm install next-firebase-auth-edge
With yarn
yarn add next-firebase-auth-edge
With pnpm
pnpm add next-firebase-auth-edge