Installation
Install theautumn-js package using your preferred package manager:
Package Exports
The SDK provides multiple entry points for different use cases:autumn-js- Core SDK (re-exports from@useautumn/sdk)autumn-js/react- React hooks and providerautumn-js/backend- Backend integration utilitiesautumn-js/hono- Hono framework adapterautumn-js/next- Next.js framework adapterautumn-js/better-auth- Better Auth plugin
Quick Start
Frontend (React)
Wrap your app with theAutumnProvider to enable React hooks:
Provider Props
Base URL for your backend server (e.g.,
"https://api.example.com"). Defaults to the current origin.Path prefix for Autumn routes. Defaults to
"/api/autumn", or "/api/auth/autumn" if useBetterAuth is enabled.Enable Better Auth integration. Sets
pathPrefix to "/api/auth/autumn" and includeCredentials to true.Include credentials (cookies) in cross-origin requests. Defaults to
true if useBetterAuth is enabled.Backend (Next.js)
Create an API route to handle Autumn requests:Backend (Hono)
Add the Autumn middleware to your Hono app:Better Auth Integration
If you’re using Better Auth, install the Autumn plugin:Backend Setup
Frontend Setup
Customer Scope Options
Determines how customer identity is resolved:
user- Customer ID is the user’s IDorganization- Customer ID is the active organization’s IDuser_and_organization- Customer ID combines user and organization IDs
Custom Identity Resolution
For advanced use cases, provide a customidentify function:
Environment Variables
Your Autumn API secret key. Get this from your Autumn dashboard.
TypeScript Support
The SDK is written in TypeScript and provides full type definitions. All hooks, methods, and responses are fully typed:Error Handling
All client methods throwAutumnClientError on failure:
AutumnClientError Properties
Human-readable error message
Machine-readable error code
HTTP status code
Additional error details if available
Next Steps
React Hooks
Learn about all available React hooks
Backend Integration
Set up backend handlers and custom routes