Password Based Auth flow for React Router and Supabase
supabase-library/password-based-auth-react-routerFreeBlock
Password Based Auth flow for React Router and Supabase
Install it
npx shadcn@latest add https://raw.githubusercontent.com/supabase/supabase/master/apps/ui-library/public/r/password-based-auth-react-router.jsonSource
1import { type EmailOtpType } from '@supabase/supabase-js'2import { redirect, type LoaderFunctionArgs } from 'react-router'34import { createClient } from '@/registry/default/clients/react-router/lib/supabase/server'56export async function loader({ request }: LoaderFunctionArgs) {7 const requestUrl = new URL(request.url)8 const token_hash = requestUrl.searchParams.get('token_hash')9 const type = requestUrl.searchParams.get('type') as EmailOtpType | null10 const _next = requestUrl.searchParams.get('next')11 const next = _next?.startsWith('/') ? _next : '/'1213 if (token_hash && type) {14 const { supabase, headers } = createClient(request)15 const { error } = await supabase.auth.verifyOtp({16 type,17 token_hash,18 })19 if (!error) {20 return redirect(next, { headers })21 } else {22 return redirect(`/auth/error?error=${error?.message}`)23 }24 }2526 // redirect the user to an error page with some instructions27 return redirect(`/auth/error?error=No token hash or type`)28}
What it pulls in
npm packages
Other registry items
Files it writes
More from Supabase Library
All 60 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Current User Avatarcurrent-user-avatar-nuxtjs | Supabase Library | Blocks | Free | 1 dep · 3 files | |
| Current User Avatarcurrent-user-avatar-vue | Supabase Library | Blocks | Free | 1 dep · 3 files | |
| Dropzone (File Upload) for Nuxt and Supabasedropzone-nuxtjs | Supabase Library | Blocks | Free | 3 deps · 4 files | |
| Dropzone (File Upload) for Vue and Supabasedropzone-vue | Supabase Library | Blocks | Free | 3 deps · 4 files | |
| Infinite Query Hookinfinite-query-hook | Supabase Library | Blocks | Free | 2 deps | |
| Password Based Auth flow for Nextjs and Supabasepassword-based-auth-nextjs | Supabase Library | Blocks | Free | 2 deps · 17 files | |
| Password Based Auth flow for Nuxt.js and Supabasepassword-based-auth-nuxtjs | Supabase Library | Blocks | Free | 2 deps · 12 files | |
| Password Based Auth flow for React and Supabasepassword-based-auth-react | Supabase Library | Blocks | Free | 1 dep · 5 files |
