H
Honoblake

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?
Blankeos
Blankeos17d 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
blake17d 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
Blankeos17d 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
Ibnu Rasikh17d ago
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
blake17d 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
More Posts
Failed to load .env file ".env": Error: ENOENT: no such file or directoryHey, Im new to using cloudflare and new to using Hono. I now came across an error that tells me Im mexecutionCtx.waitUntil on write serviceI have a worker that I want to call an external api on, but I want to return a response without awaiDoes Hono JSX do client-side hydration?I.e. are client events like on:click meant to work? And if not, how can it be enabled / done in otheStreamSSE on http2Hi ! It seems that the streamSSE feature is not correctly adapted to work on http2. It adds the follOptional params in hono/clientIt seems that it doesn't support optional params at all. In hono I can specify optional parameters, Send data to HonoHi, how can i send Request body and file on same route.Client ipHow can I get the client ip, I need it for my rate limiterWhat is the best way to handle the error?What I want is to get the error from server to client using rpc + react query 1. Using `trycatch` 2Running `bun run dev` on a newly created Cloudflare Pages example spits an error``` bun run dev $ vite (!) Could not auto-determine entry point from rollupOptions or html files andconnect my hono application endpoints with swagger uihow i can use swagger ui with my hono applicationHow to set "credentials: true" in client side using rpc?I'm using rpc with react query on the client side, this kind of fetching has already credentials: trCookies doesn't processWhen I try to run in my middleware the following ``` setCookie(c, 'test', 'res', { maxAge: 60 * 60 use Context to get vars from wrangler.tomlhow can fix this code. i want to use my openaiApiKey from the wrangler.toml when i create an openai Connect Hono Cloudflare with MongoDBHi. I am using Hono and deploying to Cloudflare. However I am unable to find a way to connect mongodCase insensitive query paramsWe are using hono-zod-openapi to replace an existing API. Sadly the old API (written in ASP.Net) appPassword hashingHow to hash password?How to setup Hono with Remix/Cloudflare for Vite dev server?From the documentation for Cloudflare Pages, there is an adapter and a plugin, but it is not clear hValidate response objectsUsing the zod validator middleware it is possible to validate params , query, request body like: ``Hono Oauth Provider with JWT issueHey everyone! I'm not sure if this is the right place for me to post about this but recently I wanteDeploy Hono / Bun APII know, I know this is such a newby question but I come from small express apps and other simple ‘cl