Skip to content

Framework recipes

handleCompileRequest takes a standard Fetch API Request and returns a Response — the same function works in every framework below without modification. Use @nandan-varma/platex for Node.js routes (with local-compile fallback) or @nandan-varma/platex/client for edge routes (remote-only).

app/api/compile/route.ts
import { handleCompileRequest } from '@nandan-varma/platex';
export const runtime = 'nodejs';
export const POST = handleCompileRequest;

To apply a client’s custom timeout / apiKey / retry without repeating them, bind the handler to a client once with createRequestHandler:

import { createPlatexClient, createRequestHandler } from '@nandan-varma/platex';
const platex = createPlatexClient({ timeout: 25_000, retry: 2 });
export const POST = createRequestHandler(platex);

This works in every framework above — swap export const POST = ... for whatever that framework’s route export looks like.