@holectus/next
v0.1.1
Published
Next.js helpers for Holectus embed integrations
Readme
@holectus/next
Next.js App Router helpers for Holectus embeds.
Use this with @holectus/react to mint short-lived access tokens on your server so the browser never sees your API key.
Install
npm install @holectus/next @holectus/coreTypically also install @holectus/react for the UI.
Peer dependencies: next >= 14.
Subject session route
app/api/holectus/session/route.ts:
import { createHolectusSessionRoute } from '@holectus/next';
export const { GET } = createHolectusSessionRoute({
scope: 'subject',
getSubjectId: async (request) => {
const url = new URL(request.url);
return url.searchParams.get('subjectId');
},
});Set on the server (not NEXT_PUBLIC_):
HOLECTUS_API_URL— Holectus API originHOLECTUS_API_KEY— dashboard API key
Then pass tokenEndpoint="/api/holectus/session?subjectId=…" to DocumentChecklist.
Admin session route
import { createHolectusSessionRoute } from '@holectus/next';
export const { GET } = createHolectusSessionRoute({
scope: 'admin',
assertAuthorized: async (request) => {
// Verify the caller is allowed to act as a Holectus admin in *your* app.
return Boolean(/* your session / role check */);
},
});