OpenInvoice uses Clerk for authentication, user management, and multi-tenant organizations. This guide covers complete Clerk setup.
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_SECRET_KEY=sk_test_...
NEXT_PUBLIC_CLERK_SIGN_IN_URL="/auth/sign-in"
NEXT_PUBLIC_CLERK_SIGN_UP_URL="/auth/sign-up"
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL="/dashboard/overview"
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL="/dashboard/overview"
In Clerk Dashboard:
http://localhost:3000/api/webhooks/clerk (use ngrok)https://yourdomain.com/api/webhooks/clerkSelect these events:
user.createduser.updateduser.deletedorganization.createdorganization.updatedorganization.deletedorganizationMembership.createdorganizationMembership.updatedorganizationMembership.deletedwhsec_)WEBHOOK_SECRET=whsec_...
Using ngrok:
ngrok http 3000
Use the ngrok URL in Clerk webhook endpoint.
free, pro, team)premium_access, advanced_reports)import { auth } from '@clerk/nextjs/server';
const hasPremiumAccess = await auth().has({ plan: 'pro' });
const hasFeature = await auth().has({ feature: 'premium_access' });
import { Protect } from '@clerk/nextjs';
<Protect
plan='pro'
fallback={<p>Upgrade to Pro to access this feature.</p>}
>
<PremiumContent />
</Protect>