Password Based Auth flow for React Router and Supabase
supabase-ui-library/password-based-auth-react-routerUnverifiedBlock
Password Based Auth flow for React Router and Supabase
Install it
npx shadcn@latest add https://raw.githubusercontent.com/aimultiple-benchmark/supabase-bench-cr-2/main/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 UI Library
All 37 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Current User Avatarcurrent-user-avatar-nuxtjs | Supabase UI Library | Blocks | Unverified | 1 dep · 3 files | |
| Current User Avatarcurrent-user-avatar-vue | Supabase UI Library | Blocks | Unverified | 1 dep · 3 files | |
| Dropzone (File Upload) for Nuxt and Supabasedropzone-nuxtjs | Supabase UI Library | Blocks | Unverified | 3 deps · 4 files | |
| Dropzone (File Upload) for Vue and Supabasedropzone-vue | Supabase UI Library | Blocks | Unverified | 3 deps · 4 files | |
| Infinite Query Hookinfinite-query-hook | Supabase UI Library | Blocks | Unverified | 2 deps | |
| Password Based Auth flow for Nextjs and Supabasepassword-based-auth-nextjs | Supabase UI Library | Blocks | Unverified | 2 deps · 17 files | |
| Password Based Auth flow for Nuxt.js and Supabasepassword-based-auth-nuxtjs | Supabase UI Library | Blocks | Unverified | 2 deps · 12 files | |
| Password Based Auth flow for React and Supabasepassword-based-auth-react | Supabase UI Library | Blocks | Unverified | 1 dep · 5 files |
