DO NOT upgrade any Clerk dependencies unless you’re following their official migration guide and understand the breaking changes. Upgrading without proper migration can break your authentication flow, webhooks, and user management. The current Clerk version in the boilerplate is tested and stable.
app/api/auth/webhook.ts
for the implementation.
When a user signs up or updates their profile in Clerk, the webhook will trigger and update your database accordingly, ensuring your user data stays in sync.
We need to make sure we create these webhooks in Clerk (both for testing locally and in production)
Testing authentication locally
Assuming you have the ngrok url running, you can test the authentication flow locally.
-
Set
config.auth.enabled
totrue
inconfig.ts
- Create a webhook in Clerk
Configure
-> Webhooks
-> + Add Endpoint
b. Set the Endpoint URL
to [your-ngrok-url]/api/auth/webhook
c. Set the Events
to user.created
and user.updated
- Run your app
- Test the authentication flow
Users
tab) and a new record created in your users
table in Supabase ✅
Configuring authentication in production
You will need to create a new webhook in Clerk AND configure your production environment with the appropriate API keys.-
Create a Production Instance of your Clerk Application
a. In your Clerk dashboard, create a new production application or switch your existing application to production mode
b. Copy your Production API Keys:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
CLERK_SECRET_KEY
- Go to
Configure
->Webhooks
->+ Add Endpoint
- Set the
Endpoint URL
tohttps://[your-production-domain]/api/auth/webhook
- Set the
Events
touser.created
anduser.updated
- Copy the webhook secret for your environment variables
d. Configure Google Auth for your production application e. Connect your custom domain in the Clerk dashboardYou can use vercel’s default domain if you haven’t bought a custom domain yet. -
Update Environment Variables
Ensure these environment variables are set in your production environment (e.g., Vercel):
- Deploy Your Application
Common Issues & Troubleshooting
To be updated soon…