awinogrodzki / next-firebase-auth-edge

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

Home Page:https://next-firebase-auth-edge-docs.vercel.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Guide

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

Docs

Official library documentation can be found at https://next-firebase-auth-edge-docs.vercel.app

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 ID Tokens 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

About

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

https://next-firebase-auth-edge-docs.vercel.app/

License:MIT License


Languages

Language:TypeScript 99.5%Language:JavaScript 0.4%Language:Shell 0.1%