auth0-fastify

Add Auth0 session-based authentication to Fastify web applications.

23|71|Updated Jul 8, 2025
One-click install
npx skills add https://github.com/auth0/docs-v2 --skill auth0-fastify
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: auth0-fastify
Source: https://github.com/auth0/docs-v2/tree/main/main/.mintlify/skills/auth0-fastify
Command: npx skills add https://github.com/auth0/docs-v2 --skill auth0-fastify

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides Fastify developers through wiring up Auth0 session-based authentication so they no longer manually build login, logout, and callback routes or session logic.

Core Features & Use Cases

  • Automatic Auth0 plugin setup: instructs how to register @auth0/auth0-fastify, add a view engine, and let Auth0 create /auth/login, /auth/logout, and /auth/callback endpoints.
  • Session-aware route protection: shows how to guard profile pages with preHandler checks, fetch the authenticated user, and obtain access tokens.
  • Environment-driven secrets: emphasizes storing the tenant domain, client ID, client secret, app base URL, and secure session secret in .env for both development and production.
  • Use Case: build a server-rendered Fastify web app that requires login, display personalized profile data, and call protected APIs without reimplementing low-level session handling.

Quick Start

Register @auth0/auth0-fastify in your Fastify server, configure environment variables for Auth0 credentials and session secrets, and protect both public and profile routes with the plugin's session helpers.

Frequently Asked Questions about auth0-fastify

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add Auth0 authentication to a Fastify web app?

To add Auth0 authentication to a Fastify web app, register the @auth0/auth0-fastify plugin, configure environment variables for credentials, and use session helpers to automatically generate login, logout, and callback routes.

How do I protect routes and manage sessions in Fastify with Auth0?

Protect routes and manage sessions in Fastify by applying preHandler checks to guard profile pages, fetch the authenticated user, and obtain access tokens using the plugin's built-in session helpers.

What environment variables do I need for Auth0 session management in Node.js?

Auth0 session management requires environment variables for the tenant domain, client ID, client secret, app base URL, and a strong session secret stored in .env for both development and production.

Does Auth0 Fastify authentication work with server-rendered applications?

Yes, Auth0 Fastify authentication is designed for server-rendered web applications, allowing you to display personalized profile data and call protected APIs without manually building low-level session handling logic.

What Node.js version is required for the Auth0 Fastify plugin?

The Auth0 Fastify plugin requires Node.js 20 or newer, along with view engine registration in your Fastify server to properly render authenticated user profiles.