Command Palette

Search for a command to run...

Quickstart

The Pylo Auth SDK (@pylo/auth-nextjs) handles user authentication for Next.js applications — login, logout, session management, and automatic token refresh.

Install

$pnpm add @pylo/auth-nextjs

Environment

.env.local
1 PYLO_API_KEY=your-api-token-here

Create an API token in Settings > API Tokens in your Pylo admin panel. See API Tokens for details.

Middleware Setup

Create a proxy.ts in your project root to handle authentication and automatic token refresh:

proxy.ts
1 2 3 4 5 6 7 8 9 10 11 12 import { createPyloProxy } from "@pylo/auth-nextjs"; export const proxy = createPyloProxy({ publicPaths: ["/auth"], }); export const config = { matcher: [ "/((?!_next/static|_next/image|favicon.ico|.*\..*|$).*)", "/", ], }

This protects all routes by default and redirects unauthenticated users to /auth/login. Tokens are refreshed automatically before they expire.

Need advanced middleware?

For custom redirect logic, route protection, or maintenance mode, see the Authentication guide.

Next Steps