Sync Clerk Data to Your Database Using Webhooks

  Рет қаралды 53,297

Hamed Bahram

Hamed Bahram

Күн бұрын

Пікірлер: 48
@uixmat
@uixmat 6 ай бұрын
It's been a while since I dived into Clerk, look's like it's come along way. Thanks for the awesome vid Hamed 🙌🏼
@hamedbahram
@hamedbahram 6 ай бұрын
Pleasure Matt 🙌🏼
@patolorde
@patolorde 7 ай бұрын
Great video as always hamed
@hamedbahram
@hamedbahram 7 ай бұрын
Thanks! I appreciate that.
@rishabhsahu9163
@rishabhsahu9163 26 күн бұрын
Which font and theme do you use in your VS Code?
@niconel7659
@niconel7659 5 ай бұрын
This was awesome. Waiting eagerly for your course.
@hamedbahram
@hamedbahram 5 ай бұрын
Awesome, thank you!
@batman_yt04
@batman_yt04 15 күн бұрын
Is there anyway to store the user ID of clerk to supabase table when the user logins into the thing can you please guide
@shezzz761
@shezzz761 7 ай бұрын
For example, when a user registers but our database is down, how do we resend the failed webhook?
@hamedbahram
@hamedbahram 7 ай бұрын
Clerk would retry the webhook automatically, you can see the retry schedule here → docs.svix.com/retries
@marvinkr
@marvinkr 6 ай бұрын
How does it work for a project in production? Where do we point ngrok?
@hamedbahram
@hamedbahram 6 ай бұрын
You don't need ngrok for production, you'll set the webhook to hit your production/deployment domain. Ngrok is just for testing in local development.
@SaraAhmed-we4xs
@SaraAhmed-we4xs 3 ай бұрын
how is svix being used here? Can I create a webhook endpoint using svix?
@hamedbahram
@hamedbahram 3 ай бұрын
Svix is a webhook sending platform, you can learn more about it here → www.svix.com
@chmod-tf7ei
@chmod-tf7ei 2 ай бұрын
very informative video most important lesson of the video: just read the docs :)
@hamedbahram
@hamedbahram 2 ай бұрын
Glad it was helpful!
@guidollaurado2319
@guidollaurado2319 3 ай бұрын
Thanks for the video, Hamed! I encountered an issue. When using the middleware provided in the tutorial, after signing out, the site redirects me directly to the login page. I need it to display the components I've created for the logged-out state. Do you know how to resolve this?
@hamedbahram
@hamedbahram 3 ай бұрын
Are you using the newer Clerk core 2.0 version or the earlier one?
@adlerspencer
@adlerspencer 6 ай бұрын
Awesome! Tks, Mr. Bahram!
@hamedbahram
@hamedbahram 6 ай бұрын
My pleasure!
@billykane917
@billykane917 2 ай бұрын
Hi sir, I think the only issue I faced for this is this is a one way sync. If I send a put request to modify the user data in mongodb it will not affect the data in clerk. How do you ensure single source of truth?
@hamedbahram
@hamedbahram 2 ай бұрын
You can update Clerk using the backend sdk so it's in sync whenever you make updates to your database. That said, it's not necessary to sync everything with Clerk, only things that would be useful in your app to have on the session perhaps.
@niconel7659
@niconel7659 5 ай бұрын
Need a little push in the right direction. So I got this all working (Clerk users in my db with roles and memberships) What would be the best way to check the current user (incl. their role/membership, which are stored in my database)? Wrap the app with my own context? But use context is client side only. Hmm...still so new, huge gaps in my knowledge
@hamedbahram
@hamedbahram 5 ай бұрын
I would use Clerk's helper function to check the current user. For instance, on the server, auth() and currentUser() are App Router-specific helpers. You can also use the `useAuth` hook on client-side. Here is a link to the docs for further reading → clerk.com/docs/references/nextjs/read-session-data
@techie.ayushsonone07
@techie.ayushsonone07 4 ай бұрын
How to use it In Production
@hamedbahram
@hamedbahram 4 ай бұрын
Same implementation, just need to update the endpoints.
@nethmalwijesinghe5244
@nethmalwijesinghe5244 6 ай бұрын
What if we want to ban a user automatically based on a thing that he does in the web app?
@hamedbahram
@hamedbahram 6 ай бұрын
Good question! You can use Clerk's backend API to programatically add a user to blocklist. You can read more here → clerk.com/docs/reference/backend-api/tag/Allow-list-Block-list#operation/CreateBlocklistIdentifier
@WebDevCodeCrush
@WebDevCodeCrush 7 ай бұрын
Great video. I’ve been struggling with this. Wasn’t sure if I should use the clerk Id as my unique user identifier in the database or something like the token Id. Wanted to make sure it was an id that would not potentially change on the clerk side. I am doing this with my Convex backend and seems to be very fast and reliable.
@hamedbahram
@hamedbahram 7 ай бұрын
Perfect! I’ve got to try Convex.
@WebDevCodeCrush
@WebDevCodeCrush 7 ай бұрын
@@hamedbahram I really tried to avoid Convex for a while, but curiousity got the best of me. I now use it for all my projects. The dev experience has been so nice and it intigrates well with Clerk. I had to rethink some things as I used to use prisma and other relational db’s, but it’s very powerful.
@tamsssss6765
@tamsssss6765 6 ай бұрын
when is the onboarding coming? =D
@hamedbahram
@hamedbahram 6 ай бұрын
in about 4 weeks
@Diary_Chronicles
@Diary_Chronicles 5 ай бұрын
Thanks a lot
@hamedbahram
@hamedbahram 5 ай бұрын
Happy to help!
@hbela1000
@hbela1000 7 ай бұрын
very good tutorial,thx.
@hamedbahram
@hamedbahram 7 ай бұрын
Glad to hear that!
@miq_5239
@miq_5239 4 ай бұрын
13:49
@hamedbahram
@hamedbahram 4 ай бұрын
👀
@miq_5239
@miq_5239 4 ай бұрын
@@hamedbahram 😂😂 thanks for the vid man, helped me a lot
@y0ake77
@y0ake77 4 ай бұрын
I didn't find this useful, why can't we see it on prisma
@hamedbahram
@hamedbahram 4 ай бұрын
Can you expand on your question? what do you mean by seeing it on Prisma?
@y0ake77
@y0ake77 4 ай бұрын
@@hamedbahram the users that signed in
@Duy-ud4fo
@Duy-ud4fo 6 ай бұрын
i got error: Error: Base64Coder: incorrect padding at Coder._getPaddingLength (webpack-internal:///(rsc)/../../../node_modules/@stablelib/base64/lib/base64.js:199:23) at Coder.decode (webpack-internal:///(rsc)/../../../node_modules/@stablelib/base64/lib/base64.js:80:34) at Object.decode (webpack-internal:///(rsc)/../../../node_modules/@stablelib/base64/lib/base64.js:213:21) at new Webhook (webpack-internal:///(rsc)/../../../node_modules/svix/dist/index.js:405:31) at POST (webpack-internal:///(rsc)/./src/app/api/webhooks/test/route.ts:30:16) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) .... POST /api/webhooks/test 500 in 59ms Can you help me?
@hamedbahram
@hamedbahram 6 ай бұрын
Not sure where that's coming form, compare your code to mine and see what you're doing different.
@dubesinhower
@dubesinhower 5 ай бұрын
I was getting the same error and I figured it out. In the Clerk documentation, it tells you to paste the webhook signing secret into your .env.local file, but for some reason, the documentation does not auto-populate your real webhook signing secret (unlike other places in the Clerk documentation). The wrong one looks like this: WEBHOOK_SECRET=whsec_123 Your real webhook signing secret is located in the Webhooks page of your Clerk dashboard inside your clerk endpoint. Hope this helps
@hamedbahram
@hamedbahram 5 ай бұрын
@@dubesinhower Thanks for sharing this.
How to build custom UIs on top of Clerk's APIs
25:02
Hamed Bahram
Рет қаралды 39 М.
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 15 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 153 МЛН
Microservices with Databases can be challenging...
20:52
Software Developer Diaries
Рет қаралды 108 М.
This is why webhooks are important
7:59
Web Dev Cody
Рет қаралды 37 М.
How To Handle Permissions Like A Senior Dev
36:39
Web Dev Simplified
Рет қаралды 276 М.
This Might Be My New Favourite Auth Library 🔥
13:25
developedbyed
Рет қаралды 35 М.
Fetching Data Doesn't Get Better Than This
6:58
Josh tried coding
Рет қаралды 138 М.
Systems Design in an Hour
1:11:00
Jordan has no life
Рет қаралды 32 М.
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 15 МЛН