docs: updated autumn plugin page with latest org feature (#4705)

This commit is contained in:
John Yeo
2025-09-16 11:01:25 -07:00
committed by Alex Yang
parent 4df178463e
commit 5359f32778
3 changed files with 93 additions and 7 deletions

View File

@@ -50,6 +50,9 @@ import { Accordion, Accordions } from "fumadocs-ui/components/accordion";
<Step>
### Add the Autumn plugin to your `auth` config
<Tabs items={["User", "Organization", "User & Organization", "Custom"]}>
<Tab value="User">
```ts title="auth.ts"
import { autumn } from "autumn-js/better-auth";
@@ -58,9 +61,68 @@ import { Accordion, Accordions } from "fumadocs-ui/components/accordion";
plugins: [autumn()],
});
```
</Tab>
<Tab value="Organization">
```ts title="auth.ts"
import { autumn } from "autumn-js/better-auth";
import { organization } from "better-auth/plugins";
export const auth = betterAuth({
// ...
plugins: [organization(), autumn({ customerScope: "organization" })],
});
```
</Tab>
<Tab value="User & Organization">
```ts title="auth.ts"
import { autumn } from "autumn-js/better-auth";
import { organization } from "better-auth/plugins";
export const auth = betterAuth({
// ...
plugins: [
organization(),
autumn({ customerScope: "user_and_organization" })
],
});
```
</Tab>
<Tab value="Custom">
```ts title="auth.ts"
import { autumn } from "autumn-js/better-auth";
import { organization } from "better-auth/plugins";
export const auth = betterAuth({
// ...
plugins: [
organization(),
autumn({
identify: async ({ session, organization }) => {
return {
customerId: "your_customer_id",
customerData: {
name: "Customer Name",
email: "customer@gmail.com",
},
};
},
}),
],
});
```
</Tab>
</Tabs>
<Callout>
Autumn will auto-create your customers when they sign up, and assign them any
default plans you created (eg your Free plan)
default plans you created (eg your Free plan). You can choose who becomes a customer: individual users, organizations, both, or something custom like workspaces.
</Callout>
</Step>
@@ -182,7 +244,7 @@ import { auth } from "@/lib/auth";
const { allowed } = await auth.api.check({
headers: await headers(), // pass the request headers
body: {
feature_id: "messages",
featureId: "messages",
},
});
@@ -192,7 +254,7 @@ const { allowed } = await auth.api.check({
await auth.api.track({
headers: await headers(),
body: {
feature_id: "messages",
featureId: "messages",
value: 2,
},
});

View File

@@ -12,6 +12,7 @@
"scripts:sync-orama": "node ./scripts/sync-orama.ts"
},
"dependencies": {
"@better-auth/utils": "0.3.0",
"@hookform/resolvers": "^5.2.1",
"@oramacloud/client": "^2.1.4",
"@radix-ui/react-accordion": "^1.2.12",
@@ -24,6 +25,7 @@
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-dropdown-menu": "^2.1.16",
"@radix-ui/react-hover-card": "^1.1.15",
"@radix-ui/react-icons": "^1.3.2",
"@radix-ui/react-label": "^2.1.7",
"@radix-ui/react-menubar": "^1.1.16",
"@radix-ui/react-navigation-menu": "^1.2.14",
@@ -49,11 +51,13 @@
"date-fns": "^4.1.0",
"embla-carousel-react": "^8.6.0",
"foxact": "^0.2.49",
"framer-motion": "^12.23.12",
"fumadocs-core": "15.7.8",
"fumadocs-docgen": "2.1.0",
"fumadocs-mdx": "11.8.3",
"fumadocs-typescript": "^4.0.6",
"fumadocs-ui": "15.7.8",
"geist": "^1.4.2",
"gray-matter": "^4.0.3",
"input-otp": "^1.4.2",
"jotai": "^2.13.1",
@@ -70,6 +74,7 @@
"react-hook-form": "^7.62.0",
"react-markdown": "^10.1.0",
"react-resizable-panels": "^3.0.5",
"react-use-measure": "^2.1.7",
"recharts": "^3.1.2",
"rehype-highlight": "^7.0.2",
"sonner": "^2.0.7",
@@ -84,6 +89,7 @@
"@types/mdx": "^2.0.13",
"@types/react": "^19.1.12",
"@types/react-dom": "^19.1.9",
"mini-svg-data-uri": "^1.4.4",
"postcss": "^8.5.6",
"tailwindcss": "^4.1.13",
"typescript": "^5.9.2"

26
pnpm-lock.yaml generated
View File

@@ -168,7 +168,7 @@ importers:
version: 0.5.1(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
'@react-three/fiber':
specifier: ^8.18.0
version: 8.18.0(1a7d56a84bc02e5ad1bde2480f0aeeca)
version: 8.18.0(de6zoezpf3ukbgngf33jdfxfpq)
'@tanstack/react-query':
specifier: ^5.85.9
version: 5.85.9(react@19.1.1)
@@ -314,6 +314,9 @@ importers:
docs:
dependencies:
'@better-auth/utils':
specifier: 0.3.0
version: 0.3.0
'@hookform/resolvers':
specifier: ^5.2.1
version: 5.2.1(react-hook-form@7.62.0(react@19.1.1))
@@ -350,6 +353,9 @@ importers:
'@radix-ui/react-hover-card':
specifier: ^1.1.15
version: 1.1.15(@types/react-dom@19.1.9(@types/react@19.1.12))(@types/react@19.1.12)(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
'@radix-ui/react-icons':
specifier: ^1.3.2
version: 1.3.2(react@19.1.1)
'@radix-ui/react-label':
specifier: ^2.1.7
version: 2.1.7(@types/react-dom@19.1.9(@types/react@19.1.12))(@types/react@19.1.12)(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
@@ -425,6 +431,9 @@ importers:
foxact:
specifier: ^0.2.49
version: 0.2.49(react@19.1.1)
framer-motion:
specifier: ^12.23.12
version: 12.23.12(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
fumadocs-core:
specifier: 15.7.8
version: 15.7.8(@oramacloud/client@2.1.4)(@tanstack/react-router@1.131.27(react-dom@19.1.1(react@19.1.1))(react@19.1.1))(@types/react@19.1.12)(algoliasearch@5.36.0)(next@15.5.2(@babel/core@7.28.4)(@playwright/test@1.55.0)(react-dom@19.1.1(react@19.1.1))(react@19.1.1)(sass@1.90.0))(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
@@ -440,6 +449,9 @@ importers:
fumadocs-ui:
specifier: 15.7.8
version: 15.7.8(@oramacloud/client@2.1.4)(@tanstack/react-router@1.131.27(react-dom@19.1.1(react@19.1.1))(react@19.1.1))(@types/react-dom@19.1.9(@types/react@19.1.12))(@types/react@19.1.12)(algoliasearch@5.36.0)(next@15.5.2(@babel/core@7.28.4)(@playwright/test@1.55.0)(react-dom@19.1.1(react@19.1.1))(react@19.1.1)(sass@1.90.0))(react-dom@19.1.1(react@19.1.1))(react@19.1.1)(tailwindcss@4.1.13)
geist:
specifier: ^1.4.2
version: 1.4.2(next@15.5.2(@babel/core@7.28.4)(@playwright/test@1.55.0)(react-dom@19.1.1(react@19.1.1))(react@19.1.1)(sass@1.90.0))
gray-matter:
specifier: ^4.0.3
version: 4.0.3
@@ -488,6 +500,9 @@ importers:
react-resizable-panels:
specifier: ^3.0.5
version: 3.0.5(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
react-use-measure:
specifier: ^2.1.7
version: 2.1.7(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
recharts:
specifier: ^3.1.2
version: 3.1.2(@types/react@19.1.12)(react-dom@19.1.1(react@19.1.1))(react-is@18.3.1)(react@19.1.1)(redux@5.0.1)
@@ -525,6 +540,9 @@ importers:
'@types/react-dom':
specifier: ^19.1.9
version: 19.1.9(@types/react@19.1.12)
mini-svg-data-uri:
specifier: ^1.4.4
version: 1.4.4
postcss:
specifier: ^8.5.6
version: 8.5.6
@@ -552,7 +570,7 @@ importers:
version: 0.15.3(solid-js@1.9.9)
'@solidjs/start':
specifier: ^1.1.7
version: 1.1.7(7c37fd26a8096bc07b4eef39619c825a)
version: 1.1.7(ccvduuxloi3j37iwckcwkycibi)
better-auth:
specifier: workspace:*
version: link:../../../packages/better-auth
@@ -15935,7 +15953,7 @@ snapshots:
optionalDependencies:
'@types/react': 19.1.12
'@react-three/fiber@8.18.0(1a7d56a84bc02e5ad1bde2480f0aeeca)':
'@react-three/fiber@8.18.0(de6zoezpf3ukbgngf33jdfxfpq)':
dependencies:
'@babel/runtime': 7.28.3
'@types/react-reconciler': 0.26.7
@@ -16388,7 +16406,7 @@ snapshots:
dependencies:
solid-js: 1.9.9
'@solidjs/start@1.1.7(7c37fd26a8096bc07b4eef39619c825a)':
'@solidjs/start@1.1.7(ccvduuxloi3j37iwckcwkycibi)':
dependencies:
'@tanstack/server-functions-plugin': 1.121.21(vite@7.1.5(@types/node@24.4.0)(jiti@2.5.1)(less@4.4.1)(lightningcss@1.30.1)(sass@1.90.0)(terser@5.44.0)(tsx@4.20.5)(yaml@2.8.1))
'@vinxi/plugin-directives': 0.5.1(vinxi@0.5.8(@azure/identity@4.11.1)(@libsql/client@0.15.14)(@netlify/blobs@10.0.8)(@types/node@24.4.0)(better-sqlite3@12.2.0)(db0@0.3.2(@libsql/client@0.15.14)(better-sqlite3@12.2.0)(drizzle-orm@0.44.5(@cloudflare/workers-types@4.20250903.0)(@libsql/client@0.15.14)(@prisma/client@5.22.0(prisma@5.22.0))(@types/better-sqlite3@7.6.13)(@types/pg@8.15.5)(better-sqlite3@12.2.0)(bun-types@1.2.21(@types/react@19.1.12))(kysely@0.28.5)(mysql2@3.14.4)(pg@8.16.3)(prisma@5.22.0))(mysql2@3.14.4))(drizzle-orm@0.44.5(@cloudflare/workers-types@4.20250903.0)(@libsql/client@0.15.14)(@prisma/client@5.22.0(prisma@5.22.0))(@types/better-sqlite3@7.6.13)(@types/pg@8.15.5)(better-sqlite3@12.2.0)(bun-types@1.2.21(@types/react@19.1.12))(kysely@0.28.5)(mysql2@3.14.4)(pg@8.16.3)(prisma@5.22.0))(ioredis@5.7.0)(jiti@2.5.1)(less@4.4.1)(lightningcss@1.30.1)(mysql2@3.14.4)(sass@1.90.0)(terser@5.44.0)(tsx@4.20.5)(yaml@2.8.1))