Next.js
A Next.js app with a sign-in card, a user button and a callback page, ready for server-side sessions.
This page is a draft. The code exists, and not all of it has been run for this page yet. The page says what was checked.
What you get
- A page with the sign-in card for a signed-out visitor and the user button for a signed-in one.
- A layout with the provider.
- A callback page.
- Three settings in
.env.local, filled in by the command.
Create it
Install the lumo CLI, then run:
lumo init --framework next
The command asks for your organization and the client ID, and writes the project and its .env file.
Settings
| Variable | Value |
|---|---|
NEXT_PUBLIC_LUMOAUTH_DOMAIN | https://app.lumoauth.dev |
NEXT_PUBLIC_LUMOAUTH_ORG_ID | Your organization. |
NEXT_PUBLIC_LUMOAUTH_CLIENT_ID | The client ID of the application. |
Files
| File | What it does |
|---|---|
app/layout.tsx | The provider. |
app/page.tsx | The sign-in card and the user button. |
app/auth/callback/page.tsx | The callback page. |
Next steps
- Keep tokens out of the browser: Server-side session in Next.js adds the route handler, the middleware and the two server settings
LUMOAUTH_CLIENT_SECRETandLUMOAUTH_SECRET. - Hide parts of the page by permission: Show and hide UI by permission.
- Protect your API: Protect routes in each framework.
- Every new organization has a "Starter App" that allows
http://localhost:3000, so the first run needs no setup in the portal.
Where the code is today
lumo init --framework next writes this project. The example app of the SDK, sdk-js/examples/nextjs, adds server-side sessions and shows every component and hook.