🛠 iron-session examples

Cookie-based sessions for Next.js

The session lives in a signed and encrypted cookie, so there is no session store to run and no lookup on the way in. Reading it is a decrypt, which is why these pages render on the server with no loading state.

Every example logs in with a fake user. Logging in sleeps 250ms to stand in for a database call; reading the session does not, because it never touches one.

Start here

App Router, the shape the Next.js authentication guide describes.

Reading the session from the client

When the session UI lives in a Client Component instead of on the server.

Other patterns

Pages Router

Same library, older router. New apps should use the App Router examples above.

How this maps to the Next.js docs

Start with Server Components and Server Actions →