Skip to main content
Fully automated for Next.js App Router. One manual step for Pages Router (wrap <Component>). Both variants scaffold correctly via npx @lucenthq/cli init.

Install with the CLI

Pick Next.js when prompted, then choose your router.

App Router

1

Environment variable

.env.local:
2

Provider component

app/providers.tsx:
3

Wire it into the root layout

app/layout.tsx:
The CLI performs all three steps automatically for App Router.

Pages Router

1

Environment variable

.env.local:
2

Wrap your app

pages/_app.tsx:
Manual step required. The CLI adds the import { LucentProvider } line to pages/_app.tsx but leaves the actual <Component> wrapping to you — the exact shape of your App export varies too much to automate safely. Copy the example above after running the CLI.

Notes

  • LucentProvider must be rendered in a client component. For App Router this means the Providers wrapper file needs "use client" at the top — the rest of your layout tree can stay a server component.
  • Use NEXT_PUBLIC_ prefix so the key is available to the browser. Never store a key that isn’t prefixed luc_pk_ in a client‑accessible variable.
  • The provider should sit at the root of your tree and never remount. If you wrap per‑page it will reset the session on every navigation.