H
Hono8mo ago
blake

How to implement Oauth in Hono?

I am a beginner. I have used next-auth in next js. Is there a way to implement google Oauth in hono? Code and youtube videos are appreciated. Is there any library i can use?
5 Replies
Blankeos
Blankeos8mo ago
Try Lucia if you're up for it. lucia-auth.com/ It's definitely not for beginners though. Setting it up is like hours of "ohhh, now i get it". It taught me some valuable auth concepts in the end tho. --- You can probably check this out as well: https://github.com/honojs/middleware/tree/main/packages/auth-js --- If you want faster options, you could use a third-party auth service: Kinde, Clerk, Firebase, Supabase.
GitHub
middleware/packages/auth-js at main · honojs/middleware
monorepo for Hono third-party middleware/helpers/wrappers - honojs/middleware
blake
blakeOP8mo ago
Do you have a sample auth code which i can use as primer? (of lucia) the github repo is v confusing i tried the given example but it uses nextjs is a lot dependency heavy. i wanted to learn how to do auth, kinde, clerk would just negate that purpose.
Blankeos
Blankeos8mo ago
Great then Lucia would be great for you! I don't have an example repo unfortunately. The repos I worked on are not public. I really just have to recommend the docs for you. Looking at these examples is already good enough tbh: https://github.com/lucia-auth/examples Few things you should note when building (from my experience): 1. Setup your Database + ORM (Drizzle or Prisma) 2. Instantiate Lucia (this will be based on either your DB driver or your ORM). Lucia has "Adapters" for those. 3. Define the tables that Lucia needs. Mainly just 1 for users, and 1 for sessions. Then, the rest of the hard parts are just setting up your controllers or resolvers or services. --- I also referred to this repo by Ben Davis quite a bit (Luckily it has implementations for GitHub and Google already which is cool) https://github.com/bmdavis419/SvelteKit-Ecommerce/tree/main/src/routes/auth/callback I was implementing mine on ElysiaJS by the way.
Ibnu Rasikh - creatypestudio.co
optionally, if you want a very simple setup and minimal code, try pocketbase. you will be suprise how easy pocketbase. and you don't need Next Auth. the only problem (but actually that's the main benefit) is pocketbase using sqlite.
blake
blakeOP8mo ago
i will read about all this and try that out! i have used prima before but i will have to look at the adapters thingg oooppsss hehe
Want results from more Discord servers?
Add your server