Skip to main content

Auth0 Next.js SDK

A powerful SDK for implementing user authentication in Next.js applications with Auth0

What is Auth0 Next.js SDK?

The Auth0 Next.js SDK is a library for implementing user authentication in Next.js applications. It provides both client-side and server-side APIs to integrate Auth0 authentication seamlessly into your Next.js app, supporting both the App Router and Pages Router.

Quick to Integrate

Get authentication up and running in minutes with minimal configuration

Secure by Default

Built-in security best practices including encrypted session cookies and CSRF protection

Full TypeScript Support

Complete type definitions for all APIs and configuration options

Flexible Session Management

Choose between stateless cookie-based sessions or stateful external storage

Key Features

Works seamlessly with both Next.js App Router and Pages Router, supporting Next.js 14, 15, and 16.
React hooks like useUser() for client-side usage and Auth0Client for server-side operations.
Supports DPoP (Demonstrating Proof-of-Possession) for token binding and Multi-Factor Authentication (MFA).
Manage multiple access tokens for different APIs with automatic token refresh per audience.
Flexible session configuration with support for rolling sessions, custom session stores, and session hooks.
Built-in proxy support for Auth0’s My Account and My Organization Management APIs.

How It Works

The SDK intercepts authentication requests at the network boundary using Next.js middleware (or proxy in Next.js 16) and handles the complete OAuth 2.0 / OIDC flow:

Package Structure

The SDK is organized into multiple entry points for different use cases:
import { useUser, getAccessToken, Auth0Provider } from '@auth0/nextjs-auth0';
Client-side React hooks and components for use in browser environments.

Next Steps

Installation

Install the SDK and configure your environment variables

Quickstart

Get a working authentication flow in under 5 minutes

Core Concepts

Learn how authentication flows work in the SDK

API Reference

Explore the complete API documentation

Requirements

  • Node.js: Version 20 LTS or newer
  • Next.js: Version 14.2.35 or newer (supports 14.x, 15.x, and 16.x)
  • React: Version 18.0.0 or newer (supports 18.x and 19.x)
  • Auth0 Account: A free Auth0 account with a Regular Web Application configured

Community & Support

GitHub Issues

Report bugs and request features

Auth0 Community

Get help from the Auth0 community

Security

Report security vulnerabilities

Build docs developers (and LLMs) love