# EXNO framework adapters 1.0.0 Add hosted checkout and verified webhooks to your server with one EXNO package. Choose Next.js, Express, Hono, Fastify, Nuxt, Remix, SvelteKit, Astro or TanStack Start. The Fetch handler also works in Web Request / Response runtimes. ## Install from EXNO This versioned package is hosted on EXNO. Install it using the full URL below; it does not require an npm registry release. Node.js 20.9+ for Node servers. The Fetch, Next.js, Hono and context handlers use Web Crypto and can run in compatible server-side edge runtimes. ```sh npm install https://exno.app/developers/adapters/1.0.0/exno-adapters-1.0.0.tgz ``` ## What the handlers do - Checkout accepts POST with product_id and an optional discount_code. Set productId or allowedProductIds on the server. Prices, quantities and arbitrary return URLs are not accepted by this checkout endpoint. - Checkout returns a 303 redirect to the published product checkout. Use response: "json" if your frontend needs the URL. Creating a URL does not confirm payment or grant product access. - Webhooks checks the original bytes and the full signing secret with HMAC-SHA256. The default timestamp window is five minutes, and the default maximum webhook body is 1 MiB. - Production is the default environment. Set environment: "staging" on both handlers for test integrations. Events from the other environment are acknowledged and ignored. Sample events are also ignored unless acceptSamples: true is explicitly set. - A matching entry in handlers runs instead of onEvent. Callback work is awaited before 200; an exception returns 500 so EXNO can retry. Store event.id with a unique constraint and update your order in the same transaction to prevent duplicate fulfilment. The adapter does not keep a temporary in-memory deduplication cache. - Keep API keys and signing secrets on your server. Use allowedOrigins for cross-origin clients and authorize for your own access check. The API key is sent only to EXNO, or an explicitly configured localhost test server; upstream redirects are never followed. ## Choose your framework ### Next.js App Router route handlers. Checkout and Webhooks return a Web Response. app/api/checkout/route.ts ```ts import { Checkout } from "@exno/adapters/nextjs"; export const POST = Checkout({ apiKey: process.env.EXNO_API_KEY!, productId: process.env.EXNO_PRODUCT_ID!, }); ``` ### Express Register the webhook route before express.json(). Use express.raw() to keep the signed bytes. server.mjs ```js import express from "express"; import { Checkout, Webhooks } from "@exno/adapters/express"; const app = express(); app.post("/webhooks/exno", express.raw({ type: "application/json" }), Webhooks({ webhookSecret: process.env.EXNO_WEBHOOK_SECRET, onEvent: async (event) => console.info(event.id, event.type), })); app.post("/checkout", express.json(), Checkout({ apiKey: process.env.EXNO_API_KEY, productId: process.env.EXNO_PRODUCT_ID, })); app.listen(3000); ``` ### Hono Uses c.req.raw. Keep this handler before any middleware that consumes the request body. app.mjs ```js import { Hono } from "hono"; import { Checkout, Webhooks } from "@exno/adapters/hono"; const app = new Hono(); app.post("/checkout", Checkout({ apiKey: process.env.EXNO_API_KEY, productId: process.env.EXNO_PRODUCT_ID, })); app.post("/webhooks/exno", Webhooks({ webhookSecret: process.env.EXNO_WEBHOOK_SECRET, onEvent: async (event) => console.info(event.id, event.type), })); export default app; ``` ### Fastify The scoped plugin preserves raw webhook bodies without changing JSON parsing on other routes. server.mjs ```js import Fastify from "fastify"; import exnoPlugin from "@exno/adapters/fastify"; const app = Fastify(); await app.register(exnoPlugin, { prefix: "/exno", checkout: { apiKey: process.env.EXNO_API_KEY, productId: process.env.EXNO_PRODUCT_ID, }, webhooks: { webhookSecret: process.env.EXNO_WEBHOOK_SECRET, onEvent: async (event) => console.info(event.id, event.type), }, }); await app.listen({ port: 3000 }); // POST /exno/checkout and /exno/webhooks/exno ``` ### Nuxt / H3 Supports H3 1 Node events and H3 2 Web Requests. Keep runtime config private. server/api/checkout.post.ts ```ts import { Checkout } from "@exno/adapters/nuxt"; export default defineEventHandler((event) => { const config = useRuntimeConfig(event); return Checkout({ apiKey: config.exnoApiKey, productId: config.exnoProductId, })(event); }); // Define exnoApiKey and exnoProductId in private runtimeConfig. // NUXT_EXNO_API_KEY and NUXT_EXNO_PRODUCT_ID supply their values. ``` ```ts // nuxt.config.ts export default defineNuxtConfig({ runtimeConfig: { exnoApiKey: "", exnoProductId: "", exnoWebhookSecret: "" }, }); ``` ### Remix / React Router Export the handler as an action. It receives the route request through the action arguments. app/routes/checkout.ts ```ts import { Checkout } from "@exno/adapters/remix"; export const action = Checkout({ apiKey: process.env.EXNO_API_KEY!, productId: process.env.EXNO_PRODUCT_ID!, }); ``` ### SvelteKit Export POST from a server route. This Node example reads only server environment variables. src/routes/checkout/+server.ts ```ts import { Checkout } from "@exno/adapters/sveltekit"; export const POST = Checkout({ apiKey: process.env.EXNO_API_KEY!, productId: process.env.EXNO_PRODUCT_ID!, }); ``` ### Astro Use an on-demand server endpoint; prerender is disabled for this route. src/pages/api/checkout.ts ```ts import { Checkout } from "@exno/adapters/astro"; export const prerender = false; export const POST = Checkout({ apiKey: process.env.EXNO_API_KEY!, productId: process.env.EXNO_PRODUCT_ID!, }); ``` ### TanStack Start Add the handler to server.handlers.POST. It receives the standard request from TanStack. src/routes/api/checkout.ts ```ts import { createFileRoute } from "@tanstack/react-router"; import { Checkout } from "@exno/adapters/tanstack"; export const Route = createFileRoute("/api/checkout")({ server: { handlers: { POST: Checkout({ apiKey: process.env.EXNO_API_KEY!, productId: process.env.EXNO_PRODUCT_ID!, }), } }, }); ``` ## Receive verified events Register the webhook URL in Dashboard → Developers → Webhooks, or create a custom app in Apps. Put its signing secret in EXNO_WEBHOOK_SECRET on your server. The example below only logs an event id and type; replace that callback with your own order processing. app/api/webhooks/exno/route.ts ```ts import { Webhooks } from "@exno/adapters/nextjs"; export const POST = Webhooks({ webhookSecret: process.env.EXNO_WEBHOOK_SECRET!, onEvent: async (event) => { // Example: records only the event id and type. // Replace with your durable, idempotent order processing. console.info("EXNO event", event.id, event.type); }, }); ``` ## Configuration and error handling Checkout supports response, allowedOrigins, authorize, timeoutMs and a local-only baseUrl. Configure allowedOrigins explicitly behind a TLS proxy; for a browser client on another origin, also configure your framework’s CORS and OPTIONS handling. Webhooks supports handlers, onEvent, acceptSamples, toleranceSeconds and maxBodyBytes. Both support onError(error, { request }). It runs on the server; shoppers receive a safe error message. See the included TypeScript declarations and guide for exact options. | Option | Meaning | | --- | --- | | `apiKey` | Checkout only. Required server-side EXNO API key. | | `productId` / `allowedProductIds` | Checkout only. Configure one fixed product or an explicit nonempty allowlist. | | `response` | `redirect` (default, HTTP 303) or `json`. | | `allowedOrigins` | Exact browser origins that may call checkout. Defaults to the request's own origin. | | `authorize(request)` | Optional application access check. Must return `true` to continue. | | `timeoutMs` | API timeout: 1–60000 ms; default 15000. No automatic API retries. | | `baseUrl` | Local HTTP origin with an explicit port only (`127.0.0.1`, `localhost`, `[::1]`). | | `webhookSecret` | Webhooks only. Full `whsec_…` signing-secret text. | | `environment` | `production` by default; `staging` for test events and API calls. | | `onEvent(event, { request })` | Awaited callback for any event without a matching named handler. | | `handlers` | Map from event type to awaited callback; a match takes precedence over `onEvent`. | | `acceptSamples` | `false` by default. Explicitly enable for sample handling; environment check still applies. | | `toleranceSeconds` | Webhook signature time window: 1–900 seconds; default 300. | | `maxBodyBytes` | Default 16 KiB for checkout, 1 MiB for webhooks. Hard caps: 64 KiB / 4 MiB. | | `onError(error, { request })` | Optional server-side error reporting. Never put secrets or full payloads in public logs. | ## Fetch / Cloudflare Workers ```js import { Webhooks } from "@exno/adapters/fetch"; export default { fetch(request, env) { return Webhooks({ webhookSecret: env.EXNO_WEBHOOK_SECRET, onEvent: async (event) => console.info(event.id, event.type), })(request); }, }; ``` Validation covers real Express, Hono, Fastify and H3 routes, NextRequest, the shared request-context contract, TypeScript and Cloudflare workerd. Checkout contract tests use a local HTTP test server; no real charge is made. Check your own callback and framework deployment before accepting live orders. ## Reference - https://exno.app/developers - https://exno.app/developers/no-code - https://nextjs.org/docs/app/api-reference/file-conventions/route - https://expressjs.com/en/api.html - https://hono.dev/docs/api/request - https://fastify.dev/docs/latest/Reference/ContentTypeParser/ - https://h3.dev/guide/api/h3event - https://v1.h3.dev/guide/event - https://svelte.dev/docs/kit/routing - https://docs.astro.build/en/guides/endpoints/ - https://tanstack.com/start/latest/docs/framework/react/guide/server-routes