Setting up authentication

Connect a provider, protect your routes, and read the current session on the server.

Last updated Jun 16, 2026

Acme Auth wraps your app in a session provider and exposes helpers for both client and server components. You can be up and running with a single provider in under five minutes.

Install the provider

Add the provider at the root of your application so every route can read the session. It is safe to render on the server and streams no secrets to the client.

import { AuthProvider } from "@acme/auth"

export default function RootLayout({ children }) {
  return <AuthProvider>{children}</AuthProvider>
}

Protect a route

Call the session helper in any server component. If there is no active session it redirects to your sign-in page automatically.