Skip to main content
The autumnHandler creates server-side endpoints that handle communication between your frontend React hooks and Autumn’s API. It manages customer authentication and proxies requests securely using your secret key.
Learn how to setup Autumn hooks in the Getting Started guide.

Framework adapters

Import the handler from the adapter that matches your backend framework:
FrameworkImport path
Next.jsautumn-js/next
Honoautumn-js/hono
Elysia / Web Standardautumn-js/fetch
Expressautumn-js/express
Otherautumn-js/backend
The Web Standard adapter (autumn-js/fetch) works with any runtime that uses the Fetch API Request/Response objects, including Elysia, Cloudflare Workers, and Deno.
The Express adapter requires express.json() body-parser middleware before the Autumn handler. See the setup guide for full examples.

Usage

// app/api/autumn/[...all]/route.ts
import { autumnHandler } from "autumn-js/next";
import { auth } from "@clerk/nextjs/server";

export const { GET, POST } = autumnHandler({
  identify: async () => {
    const { userId } = await auth();
    return { customerId: userId };
  },
});

Parameters

identify
(request: Request) => AuthResult
required
Function that receives the incoming request and returns customer identification data.
secretKey
string
Autumn API secret key. Defaults to AUTUMN_SECRET_KEY environment variable.
autumnURL
string
Override the Autumn API URL. Use when self-hosting.
pathPrefix
string
Path prefix for routes. Defaults to /api/autumn.
suppressLogs
boolean
If true, suppresses console warnings and logs.