Next.js SDK
@sentriq/next builds on @sentriq/react and @sentriq/node — never duplicating either. App Router is the target; Pages Router is possible but not officially tested.
Install
npm install @sentriq/next@sentriq/next/client and @sentriq/next/server are the ONLY import paths — there is no bare @sentriq/next import. This is the actual security boundary that keeps a secret key out of a client bundle, not just a naming convention — the client entry point's module graph contains no reference to the server SDK at all.Client Components
'use client';
import { SentriqProvider, useSentriq } from '@sentriq/next/client';
export function Providers({ children }: { children: React.ReactNode }) {
return (
<SentriqProvider publicKey={process.env.NEXT_PUBLIC_SENTRIQ_PUBLIC_KEY!}>
{children}
</SentriqProvider>
);
}Only NEXT_PUBLIC_-prefixed environment variables ever reach the browser — that's a Next.js platform behavior, not something this SDK adds. Use NEXT_PUBLIC_SENTRIQ_PUBLIC_KEY / NEXT_PUBLIC_SENTRIQ_API_URL here; neverSENTRIQ_SECRET_KEY.
Server Components / Route Handlers / Server Actions
// app/api/events/[id]/route.ts — a Route Handler
import { Sentriq } from '@sentriq/next/server';
const sentriq = new Sentriq({ secretKey: process.env.SENTRIQ_SECRET_KEY! });
export async function GET(_req: Request, { params }: { params: { id: string } }) {
const event = await sentriq.events.retrieve(params.id);
return Response.json(event);
}SENTRIQ_SECRET_KEY — a plain (non-NEXT_PUBLIC_) environment variable — stays server-only automatically, since Next.js never inlines it into a client bundle, and @sentriq/next/server is never importable from a 'use client' file in the first place.
Resources & errors
Identical to @sentriq/react (client) and @sentriq/node (server) — both re-exported unchanged.
Version compatibility
Next.js >=14.0.0 (peer range); React 19.2.8 tested this phase. App Router targeted first — Pages Router is possible (nothing here is App-Router-exclusive) but not officially tested.