next-firebase-auth-edge
TypeScript icon, indicating that this package has built-in type declarations

1.4.3 • Public • Published
next-firebase-auth-edge

Next.js Firebase Authentication for Edge and Node.js runtimes. Use Firebase Authentication with latest Next.js features.

npm version

Example

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

Why

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 JWT tokens provided by Firebase Authentication using Web Crypto API available inside Edge runtimes.

Features

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

What's new in v1.4

  • handleInvalidToken is now being called with InvalidTokenReason to give developer more control over authentication flow
  • You can now use the library without providing service account credentials in authenticated Google Cloud Run environment
  • You can now use the library in Firebase Hosting environment by changing cookieName to __session
  • You can enable debug mode in authentication middleware

Installation

With npm

npm install next-firebase-auth-edge

With yarn

yarn add next-firebase-auth-edge

With pnpm

pnpm add next-firebase-auth-edge

Package Sidebar

Install

npm i next-firebase-auth-edge

Weekly Downloads

3,636

Version

1.4.3

License

MIT

Unpacked Size

1.51 MB

Total Files

320

Last publish

Collaborators

  • awinogrodzki