Clerk
Integrate Lumen with Clerk
Automatically assign your free plan to new users
In order for entitlements to work, all your users should have a plan assigned. We recommend automatically assigning your free plan to every new user in your auth system.
Requirements
You must have an active free plan. If you don't, create one at Plans.
Installation
-
Create a new webhook subscribed to
user.created
. Navigate to Configure > Webhooks in Clerk dashboard. -
Set the webhook URL to:
https://api.getlumen.dev/v1/webhooks/clerk
-
After the webhook is created, click on the Advanced tab and add the following header:
- Key:
Authorization
- Value:
Bearer your_secret_api_key
If you don't have an API Key, you can create one at API Keys.
- Key:
UI Components
You only need to do this if you want to use our built-in UI Components Pricing Table, Usage Badge.
If you are using NextJS, you will need to add this code in api/lumen/[...all]/route.ts
. Using another framework and have questions? Email us at founders@getlumen.dev and we will reply in less than 1h if we are awake.
import { NextRequest, NextResponse } from "next/server";
import { lumenNextHandler } from "@getlumen/server";
import { auth } from "@clerk/nextjs/server";
const handler = async (request: NextRequest) => {
const { userId } = await auth();
if (!userId) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
return NextResponse.json(
await lumenNextHandler({
request,
userId,
})
);
};
export {
handler as GET,
handler as POST,
handler as PUT,
handler as DELETE,
handler as PATCH,
handler as OPTIONS,
handler as HEAD,
};