Signing users in to the client portal
An Analytics button in your app can open your user’s client portal, already signed in.
app/api/analytics/route.ts
import { stats } from '@/lib/stats';
export async function GET() {
const user = await currentUser(); // your own sign-in
// Safe to repeat: the same email again only updates the name or role.
// invite: false, or each call would email a set-password link (the default is true).
await stats.users.add(user.id, { email: user.email, name: user.name, invite: false });
const { url } = await stats.users.loginLink(user.id, user.email, { site: website.id });
return Response.redirect(url); // works once, within 5 minutes; opens that site's page
} - People with two-step sign-in get the sign-in page instead (
signs_in: falsein the answer). - Each new link replaces the last one for that person.
- Roles:
admin(the default) orviewer.users.list(ref)andusers.remove(ref, email)manage the rest.
What your users see there is in the Client portal docs.
Was this helpful?
Thanks for your feedback!
✓ Feedback received. Thank you!



