Skip to main content
@firstflow/runtime works in any React setup. In Next.js (App Router) the only rules are the usual ones: the provider is a client component, and your server-only Supabase key never crosses into the browser.

Provider in a client component

The provider uses hooks and localStorage, so it must run on the client. Wrap it in a "use client" component and mount that in your layout.
app/firstflow-provider.tsx
app/layout.tsx

Environment variables

Only the browser-safe pair carries the NEXT_PUBLIC_ prefix. The server SDK’s service_role key must not:

Wrapping LLM calls in route handlers

Use the server SDK inside route handlers (or server actions), where the service_role key is safe:
app/api/chat/route.ts

Notes

  • The browser runtime has no conversation id. Link the two sides by passing the same user.id to the provider and to your server calls; the server-side conversationId/sessionId is owned by your own chat code.
  • Identify users from your auth in the client component (user={...}); omit it for anonymous visitors.