implement-saaskit-nextjs
Installation
SKILL.md
Implement SaaSKit Next.js
Add login, callback, a scalekit_session cookie, logout, and refresh in the App Router. Then stop.
Guardrails
- MUST re-check the session in Server Components. Middleware cookie-presence is not enough.
- MUST keep
redirectUriidentical to the dashboard Allowed callback URL. - MUST set
sameSite: 'lax'on every auth cookie. MUST NOT use'strict'— it drops the cookie on the OAuth callback. - MUST treat
nextas a relative path only (/..., not//…). MUST NOT redirect to an arbitrary URL.
Gotchas
setup-saaskitalready wrote env and registered the redirect. Start there.- Read
SCALEKIT_ENVIRONMENT_URL,SCALEKIT_CLIENT_ID,SCALEKIT_CLIENT_SECRET, andSCALEKIT_REDIRECT_URI. NeverSCALEKIT_ENV_URL. Do not prependhttps://. - One
scalekit_sessionJSON HttpOnly cookie. Do not copy Express path-scoped cookies fromimplement-saaskit. ScalekitClientis Node-only. Do not import it inmiddleware.ts(Edge).- FSA scopes include
offline_access.refreshAccessTokenreturns{ accessToken, refreshToken }only. getLogoutUrl({ idTokenHint, postLogoutRedirectUri }). Register that post-logout URL.