🛠 iron-session examples

Server Components and Server Actions

App Router

How to test: Login and refresh the page to see iron-session in action.

Protected page → redirects back here unless you are logged in, checked in the Data Access Layer.

GitHub Logo Get the code for this example
How it works
  1. During login, the page uses a server action.
  2. During logout, the page uses a server action.
  3. When displaying session data, the server component gets the data and pass it to the page.

← All examples