The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: uses iframes for UI lib examples. (#34419)
Jonathan Summers-Muir846b470f9dc8
diff --git a/apps/ui-library/__registry__/index.tsx b/apps/ui-library/__registry__/index.tsxindex a3fcd4b347e..14e3098441a 100644--- a/apps/ui-library/__registry__/index.tsx+++ b/apps/ui-library/__registry__/index.tsx@@ -222,6 +222,18 @@ export const Index: Record<string, any> = {subcategory: "undefined",chunks: []}+ ,+ "password-based-auth-demo": {+ name: "password-based-auth-demo",+ type: "registry:example",+ registryDependencies: [],+ component: React.lazy(() => import("@/registry/default/examples/password-based-auth.tsx")),+ source: "",+ files: ["registry/default/examples/password-based-auth.tsx"],+ category: "undefined",+ subcategory: "undefined",+ chunks: []+ }},}diff --git a/apps/ui-library/app/(app)/layout.tsx b/apps/ui-library/app/(app)/layout.tsxindex 49b81a77a8f..ce1fc693618 100644--- a/apps/ui-library/app/(app)/layout.tsx+++ b/apps/ui-library/app/(app)/layout.tsx@@ -24,7 +24,9 @@ export default function AppLayout({ children }: AppLayoutProps) {<SideNavigation /></ScrollArea></aside>- {children}+ <div vaul-drawer-wrapper="">+ <div className="relative flex min-h-screen flex-col bg-background">{children}</div>+ </div></div></div></main>diff --git a/apps/ui-library/app/example/base-injector.tsx b/apps/ui-library/app/example/base-injector.tsxnew file mode 100644index 00000000000..5d8941bfafd--- /dev/null+++ b/apps/ui-library/app/example/base-injector.tsx@@ -0,0 +1,22 @@+'use client'++import { useEffect } from 'react'++export function BaseInjector() {+ useEffect(() => {+ // Remove any existing base tag+ const existingBase = document.querySelector('base')+ if (existingBase) existingBase.remove()++ // Add new base tag+ const base = document.createElement('base')+ base.href = `${process.env.NEXT_PUBLIC_BASE_PATH ?? ''}/example/password-based-auth/`+ document.head.prepend(base)++ return () => {+ base.remove()+ }+ }, [])++ return null+}diff --git a/apps/ui-library/app/example/password-based-auth/forgot-password/page.tsx b/apps/ui-library/app/example/password-based-auth/forgot-password/page.tsxnew file mode 100644index 00000000000..de915093bcf--- /dev/null+++ b/apps/ui-library/app/example/password-based-auth/forgot-password/page.tsx@@ -0,0 +1,5 @@+import { ForgotPasswordForm } from '@/registry/default/blocks/password-based-auth-nextjs/components/forgot-password-form'++export default function Page() {+ return <ForgotPasswordForm />+}diff --git a/apps/ui-library/app/example/password-based-auth/layout.tsx b/apps/ui-library/app/example/password-based-auth/layout.tsxnew file mode 100644index 00000000000..092ea3fb06c--- /dev/null+++ b/apps/ui-library/app/example/password-based-auth/layout.tsx@@ -0,0 +1,45 @@+import { Metadata } from 'next'+import { BaseInjector } from './../base-injector'+import { ThemeProvider } from '@/app/Providers'++export const metadata: Metadata = {+ title: 'Password Based Auth Example',+}++export default function RootLayout({ children }: { children: React.ReactNode }) {+ return (+ <html style={{ height: '100%', overflow: 'hidden' }}>+ <head>+ <style+ dangerouslySetInnerHTML={{+ __html: `+ html, body, #root, main {+ height: 100% !important;+ min-height: 100% !important;+ margin: 0 !important;+ padding: 0 !important;+ overflow: hidden !important;+ }+ `,+ }}+ />+ </head>+ <body style={{ height: '100%', margin: 0, padding: 0, overflow: 'hidden' }}>+ <BaseInjector />+ <ThemeProvider+ themes={['dark', 'light', 'classic-dark']}+ defaultTheme="system"+ enableSystem+ >+ <div+ className="flex w-full h-full items-center justify-center p-6 md:p-10 preview bg"+ style={{ minHeight: '100%' }}+ >+ <div className="z-0 pointer-events-none absolute h-full w-full bg-[radial-gradient(hsla(var(--foreground-default)/0.05)_1px,transparent_1px)] [background-size:16px_16px] [mask-image:radial-gradient(ellipse_50%_50%_at_50%_50%,#000_70%,transparent_100%)]"></div>+ <div className="w-full max-w-sm">{children}</div>+ </div>+ </ThemeProvider>+ </body>+ </html>+ )+}diff --git a/apps/ui-library/app/example/password-based-auth/login/page.tsx b/apps/ui-library/app/example/password-based-auth/login/page.tsxnew file mode 100644index 00000000000..6b4f19dc9d8--- /dev/null+++ b/apps/ui-library/app/example/password-based-auth/login/page.tsx@@ -0,0 +1,7 @@+import { LoginForm } from '@/registry/default/blocks/password-based-auth-nextjs/components/login-form'++const PasswordBasedAuthDemo = () => {+ return <LoginForm />+}++export default PasswordBasedAuthDemodiff --git a/apps/ui-library/app/example/password-based-auth/protected/SignOutButton.tsx b/apps/ui-library/app/example/password-based-auth/protected/SignOutButton.tsxnew file mode 100644index 00000000000..50947760f00--- /dev/null+++ b/apps/ui-library/app/example/password-based-auth/protected/SignOutButton.tsx@@ -0,0 +1,22 @@+'use client'++import { Button } from '@/registry/default/components/ui/button'+import { createClient } from '@/registry/default/clients/nextjs/lib/supabase/client'+import { useRouter } from 'next/navigation'++export function SignOutButton() {+ const supabase = createClient()+ const router = useRouter()++ return (+ <Button+ variant="outline"+ onClick={() => {+ supabase.auth.signOut()+ router.push('/example/password-based-auth/login')+ }}+ >+ Sign out+ </Button>+ )+}diff --git a/apps/ui-library/app/example/password-based-auth/protected/page.tsx b/apps/ui-library/app/example/password-based-auth/protected/page.tsxnew file mode 100644index 00000000000..f610f6151c0--- /dev/null+++ b/apps/ui-library/app/example/password-based-auth/protected/page.tsx@@ -0,0 +1,20 @@+import { redirect } from 'next/navigation'++import { createClient } from '@/registry/default/clients/nextjs/lib/supabase/server'+import { SignOutButton } from './SignOutButton'++export default async function ProtectedPage() {+ const supabase = await createClient()++ const { data, error } = await supabase.auth.getUser()+ if (error || !data?.user) {+ redirect('/login')+ }++ return (+ <>+ <p>Hello {data.user.email}</p>+ <SignOutButton />+ </>+ )+}diff --git a/apps/ui-library/app/example/password-based-auth/sign-up-success/page.tsx b/apps/ui-library/app/example/password-based-auth/sign-up-success/page.tsxnew file mode 100644index 00000000000..b265cabf808--- /dev/null+++ b/apps/ui-library/app/example/password-based-auth/sign-up-success/page.tsx@@ -0,0 +1,30 @@+import {+ Card,+ CardContent,+ CardDescription,+ CardHeader,+ CardTitle,+} from '@/registry/default/components/ui/card'++export default function Page() {+ return (+ <div className="flex min-h-svh w-full items-center justify-center p-6 md:p-10">+ <div className="w-full max-w-sm">+ <div className="flex flex-col gap-6">+ <Card>+ <CardHeader>+ <CardTitle className="text-2xl">Thank you for signing up!</CardTitle>+ <CardDescription>Check your email to confirm</CardDescription>+ </CardHeader>+ <CardContent>+ <p className="text-sm text-muted-foreground">+ You've successfully signed up. Please check your email to confirm your account+ before signing in.+ </p>+ </CardContent>+ </Card>+ </div>+ </div>+ </div>+ )+}diff --git a/apps/ui-library/app/example/password-based-auth/sign-up/page.tsx b/apps/ui-library/app/example/password-based-auth/sign-up/page.tsxnew file mode 100644index 00000000000..8813510eada--- /dev/null+++ b/apps/ui-library/app/example/password-based-auth/sign-up/page.tsx@@ -0,0 +1,7 @@+import { SignUpForm } from '@/registry/default/blocks/password-based-auth-nextjs/components/sign-up-form'++const PasswordBasedAuthDemo = () => {+ return <SignUpForm />+}++export default PasswordBasedAuthDemodiff --git a/apps/ui-library/app/example/password-based-auth/update-password/page.tsx b/apps/ui-library/app/example/password-based-auth/update-password/page.tsxnew file mode 100644index 00000000000..8ce3c98205e--- /dev/null+++ b/apps/ui-library/app/example/password-based-auth/update-password/page.tsx@@ -0,0 +1,11 @@+import { UpdatePasswordForm } from '@/registry/default/blocks/password-based-auth-nextjs/components/update-password-form'++export default function Page() {+ return (+ <div className="flex min-h-svh w-full items-center justify-center p-6 md:p-10">+ <div className="w-full max-w-sm">+ <UpdatePasswordForm />+ </div>+ </div>+ )+}diff --git a/apps/ui-library/app/example/realtime-cursor/layout.tsx b/apps/ui-library/app/example/realtime-cursor/layout.tsxnew file mode 100644index 00000000000..903fc572646--- /dev/null+++ b/apps/ui-library/app/example/realtime-cursor/layout.tsx@@ -0,0 +1,17 @@+import { Metadata } from 'next'+import { BaseInjector } from './../base-injector'++export const metadata: Metadata = {+ title: 'Realtime Cursor Example',+}++export default function RootLayout({ children }: { children: React.ReactNode }) {+ return (+ <>+ <BaseInjector />+ <div className="flex w-full items-center justify-center p-6 md:p-10 preview">+ <div className="w-full max-w-sm">{children}</div>+ </div>+ </>+ )+}diff --git a/apps/ui-library/app/example/realtime-cursor/page.tsx b/apps/ui-library/app/example/realtime-cursor/page.tsxnew file mode 100644index 00000000000..33f96c19f32--- /dev/null+++ b/apps/ui-library/app/example/realtime-cursor/page.tsx@@ -0,0 +1,26 @@+'use client'++import { RealtimeCursors } from '@/registry/default/blocks/realtime-cursor/components/realtime-cursors'+import { Input } from '@/registry/default/components/ui/input'+import { Label } from '@/registry/default/components/ui/label'+import { useEffect, useState } from 'react'++const names = ['Eren', 'Armin', 'Mikasa', 'Reiner', 'Levi', 'Bertholdt']++const RealtimeCursorDemo = () => {+ const [username, setUsername] = useState('')++ useEffect(() => {+ setUsername(names[Math.floor(Math.random() * names.length)])+ }, [])++ return (+ <div className="flex flex-col w-40 gap-3">+ <Label>Username</Label>+ <Input value={username} onChange={(e) => setUsername(e.target.value)} />+ <RealtimeCursors roomName="realtime-cursor-example" username={username} />+ </div>+ )+}++export default RealtimeCursorDemodiff --git a/apps/ui-library/app/layout.tsx b/apps/ui-library/app/layout.tsxindex 98057988337..df931d24076 100644--- a/apps/ui-library/app/layout.tsx+++ b/apps/ui-library/app/layout.tsx@@ -25,9 +25,8 @@ export default async function Layout({ children }: RootLayoutProps) {defaultTheme="system"enableSystem>- <div vaul-drawer-wrapper="">- <div className="relative flex min-h-screen flex-col bg-background">{children}</div>- </div>+ {children}+<SonnerToaster /></ThemeProvider></body>diff --git a/apps/ui-library/components/block-preview.tsx b/apps/ui-library/components/block-preview.tsxnew file mode 100644index 00000000000..f132579de92--- /dev/null+++ b/apps/ui-library/components/block-preview.tsx@@ -0,0 +1,42 @@+'use client'++import * as React from 'react'+import { cn } from 'ui'++interface ComponentPreviewProps extends React.HTMLAttributes<HTMLDivElement> {+ name: string+ wide?: boolean+}++export function BlockPreview({ name, wide = false }: ComponentPreviewProps) {+ const BlockPreview = React.useMemo(() => {+ return (+ <div className="w-full h-full flex items-center justify-center">+ <React.Suspense+ fallback={+ <div className="flex items-center text-sm text-muted-foreground">Loading...</div>+ }+ >+ <iframe+ src={`/ui/example/${name}`}+ style={{+ border: 'none',+ width: '100%',+ height: '100%',+ display: 'block',+ }}+ name="preview-frame"+ />+ </React.Suspense>+ </div>+ )+ }, [name])++ const wideClasses = wide ? '2xl:-ml-12 2xl:-mr-12' : ''++ return (+ <div className={cn('mt-4 w-full', wideClasses)}>+ <div className={cn('relative border bg-studio min-h-[350px] h-[600px]')}>{BlockPreview}</div>+ </div>+ )+}diff --git a/apps/ui-library/components/component-preview.tsx b/apps/ui-library/components/component-preview.tsxindex 6e77d64514e..0b02b88b3ad 100644--- a/apps/ui-library/components/component-preview.tsx+++ b/apps/ui-library/components/component-preview.tsx@@ -45,7 +45,7 @@ export function ComponentPreview({const [expand, setExpandState] = React.useState(false)const Preview = React.useMemo(() => {- const Component = Index[config.style][name]?.component+ const Component = Index['default'][name]?.componentif (!Component) {return (diff --git a/apps/ui-library/components/mdx-components.tsx b/apps/ui-library/components/mdx-components.tsxindex 19f30f7bdf2..fdd78766262 100644--- a/apps/ui-library/components/mdx-components.tsx+++ b/apps/ui-library/components/mdx-components.tsx@@ -35,6 +35,7 @@ import {} from 'ui'import { Admonition } from 'ui-patterns/admonition'import { BlockItem } from './block-item'+import { BlockPreview } from './block-preview'import { ComponentProps } from './component-props'import { SonnerExpandConfig } from './sonner-expand-config'import { SonnerPositionConfig } from './sonner-expand-position'@@ -273,6 +274,7 @@ const components = {SonnerExpandConfig,SonnerPositionConfig,BlockItem,+ BlockPreview,}interface MdxProps {diff --git a/apps/ui-library/content/docs/nextjs/password-based-auth.mdx b/apps/ui-library/content/docs/nextjs/password-based-auth.mdxindex 4284410e099..0de95f33dea 100644--- a/apps/ui-library/content/docs/nextjs/password-based-auth.mdx+++ b/apps/ui-library/content/docs/nextjs/password-based-auth.mdx@@ -3,6 +3,8 @@ title: Password-based Auth (Next.js)description: Password-based Auth block for Next.js app---+<BlockPreview name="password-based-auth/sign-up" />+## Installation<BlockItemdiff --git a/apps/ui-library/content/docs/nextjs/realtime-cursor.mdx b/apps/ui-library/content/docs/nextjs/realtime-cursor.mdxindex 71a06756f55..5de5fda8b69 100644--- a/apps/ui-library/content/docs/nextjs/realtime-cursor.mdx+++ b/apps/ui-library/content/docs/nextjs/realtime-cursor.mdx@@ -3,10 +3,12 @@ title: Realtime Cursordescription: Real-time cursor sharing for collaborative applications----<ComponentPreview- name="realtime-cursor-demo"- description="An alert with an icon, title and description. The title says 'Heads up!' and the description is 'You can add components to your app using the cli.'."-/>+<div className="flex flex-row -space-x-px w-full">++<BlockPreview name="realtime-cursor" />+<BlockPreview name="realtime-cursor" />++</div>## Installationdiff --git a/apps/ui-library/package.json b/apps/ui-library/package.jsonindex aa11ebc5ef9..62af2840d67 100644--- a/apps/ui-library/package.json+++ b/apps/ui-library/package.json@@ -7,7 +7,7 @@"preinstall": "npx only-allow pnpm","dev": "next dev --port 3004","build": "pnpm run content:build && pnpm run build:registry && pnpm run build:llms && next build",- "build:registry": "tsx --tsconfig ./tsconfig.scripts.json ./scripts/build-registry.mts && prettier --write registry.json && rimraf -G public/r && shadcn build",+ "build:registry": "tsx --tsconfig ./tsconfig.scripts.json ./scripts/build-registry.mts && prettier --write registry.json && rimraf -G public/r && shadcn build && tsx scripts/clean-registry.ts","build:llms": "tsx --tsconfig ./tsconfig.scripts.json ./scripts/build-llms-txt.ts","start": "next start","lint": "next lint",diff --git a/apps/ui-library/public/r/password-based-auth-nextjs.json b/apps/ui-library/public/r/password-based-auth-nextjs.jsonindex 5acf598499a..348e51cb08b 100644--- a/apps/ui-library/public/r/password-based-auth-nextjs.json+++ b/apps/ui-library/public/r/password-based-auth-nextjs.json@@ -63,7 +63,7 @@},{"path": "registry/default/blocks/password-based-auth-nextjs/components/sign-up-form.tsx",- "content": "'use client'\n\nimport { cn } from '@/lib/utils'\nimport { createClient } from '@/registry/default/clients/nextjs/lib/supabase/client'\nimport { Button } from '@/registry/default/components/ui/button'\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from '@/registry/default/components/ui/card'\nimport { Input } from '@/registry/default/components/ui/input'\nimport { Label } from '@/registry/default/components/ui/label'\nimport Link from 'next/link'\nimport { useRouter } from 'next/navigation'\nimport { useState } from 'react'\n\nexport function SignUpForm({ className, ...props }: React.ComponentPropsWithoutRef<'div'>) {\n const [email, setEmail] = useState('')\n const [password, setPassword] = useState('')\n const [repeatPassword, setRepeatPassword] = useState('')\n const [error, setError] = useState<string | null>(null)\n const [isLoading, setIsLoading] = useState(false)\n const router = useRouter()\n const supabase = createClient()\n\n const handleSignUp = async (e: React.FormEvent) => {\n e.preventDefault()\n setIsLoading(true)\n setError(null)\n\n if (password !== repeatPassword) {\n setError('Passwords do not match')\n setIsLoading(false)\n return\n }\n\n try {\n const { error } = await supabase.auth.signUp({\n email,\n password,\n })\n if (error) throw error\n router.push('/sign-up-success')\n } catch (error: unknown) {\n setError(error instanceof Error ? error.message : 'An error occurred')\n } finally {\n setIsLoading(false)\n }\n }\n\n return (\n <div className={cn('flex flex-col gap-6', className)} {...props}>\n <Card>\n <CardHeader>\n <CardTitle className=\"text-2xl\">Sign up</CardTitle>\n <CardDescription>Create a new account</CardDescription>\n </CardHeader>\n <CardContent>\n <form onSubmit={handleSignUp}>\n <div className=\"flex flex-col gap-6\">\n <div className=\"grid gap-2\">\n <Label htmlFor=\"email\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n placeholder=\"[email protected]\"\n required\n value={email}\n onChange={(e) => setEmail(e.target.value)}\n />\n </div>\n <div className=\"grid gap-2\">\n <div className=\"flex items-center\">\n <Label htmlFor=\"password\">Password</Label>\n </div>\n <Input\n id=\"password\"\n type=\"password\"\n required\n value={password}\n onChange={(e) => setPassword(e.target.value)}\n />\n </div>\n <div className=\"grid gap-2\">\n <div className=\"flex items-center\">\n <Label htmlFor=\"repeat-password\">Repeat Password</Label>\n </div>\n <Input\n id=\"repeat-password\"\n type=\"password\"\n required\n value={repeatPassword}\n onChange={(e) => setRepeatPassword(e.target.value)}\n />\n </div>\n {error && <p className=\"text-sm text-red-500\">{error}</p>}\n <Button type=\"submit\" className=\"w-full\" disabled={isLoading}>\n {isLoading ? 'Creating an account...' : 'Sign up'}\n </Button>\n </div>\n <div className=\"mt-4 text-center text-sm\">\n Already have an account?{' '}\n <Link href=\"/login\" className=\"underline underline-offset-4\">\n Login\n </Link>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n )\n}\n",+ "content": "'use client'\n\nimport { cn } from '@/lib/utils'\nimport { createClient } from '@/registry/default/clients/nextjs/lib/supabase/client'\nimport { Button } from '@/registry/default/components/ui/button'\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from '@/registry/default/components/ui/card'\nimport { Input } from '@/registry/default/components/ui/input'\nimport { Label } from '@/registry/default/components/ui/label'\nimport { Link } from '@/registry/default/components/ui/link'\nimport { useRouter } from 'next/navigation'\nimport { useState } from 'react'\n\nexport function SignUpForm({ className, ...props }: React.ComponentPropsWithoutRef<'div'>) {\n const [email, setEmail] = useState('')\n const [password, setPassword] = useState('')\n const [repeatPassword, setRepeatPassword] = useState('')\n const [error, setError] = useState<string | null>(null)\n const [isLoading, setIsLoading] = useState(false)\n const router = useRouter()\n const supabase = createClient()\n\n const handleSignUp = async (e: React.FormEvent) => {\n e.preventDefault()\n setIsLoading(true)\n setError(null)\n\n if (password !== repeatPassword) {\n setError('Passwords do not match')\n setIsLoading(false)\n return\n }\n\n try {\n const { error } = await supabase.auth.signUp({\n email,\n password,\n options: {\n emailRedirectTo: `${window.location.origin}/protected`,\n },\n })\n if (error) throw error\n router.push('/sign-up-success')\n } catch (error: unknown) {\n setError(error instanceof Error ? error.message : 'An error occurred')\n } finally {\n setIsLoading(false)\n }\n }\n\n return (\n <div className={cn('flex flex-col gap-6', className)} {...props}>\n <Card>\n <CardHeader>\n <CardTitle className=\"text-2xl\">Sign up</CardTitle>\n <CardDescription>Create a new account</CardDescription>\n </CardHeader>\n <CardContent>\n <form onSubmit={handleSignUp}>\n <div className=\"flex flex-col gap-6\">\n <div className=\"grid gap-2\">\n <Label htmlFor=\"email\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n placeholder=\"[email protected]\"\n required\n value={email}\n onChange={(e) => setEmail(e.target.value)}\n />\n </div>\n <div className=\"grid gap-2\">\n <div className=\"flex items-center\">\n <Label htmlFor=\"password\">Password</Label>\n </div>\n <Input\n id=\"password\"\n type=\"password\"\n required\n value={password}\n onChange={(e) => setPassword(e.target.value)}\n />\n </div>\n <div className=\"grid gap-2\">\n <div className=\"flex items-center\">\n <Label htmlFor=\"repeat-password\">Repeat Password</Label>\n </div>\n <Input\n id=\"repeat-password\"\n type=\"password\"\n required\n value={repeatPassword}\n onChange={(e) => setRepeatPassword(e.target.value)}\n />\n </div>\n {error && <p className=\"text-sm text-red-500\">{error}</p>}\n <Button type=\"submit\" className=\"w-full\" disabled={isLoading}>\n {isLoading ? 'Creating an account...' : 'Sign up'}\n </Button>\n </div>\n <div className=\"mt-4 text-center text-sm\">\n Already have an account?{' '}\n <Link href=\"/login\" className=\"underline underline-offset-4\">\n Login\n </Link>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n )\n}\n","type": "registry:component"},{@@ -80,7 +80,7 @@},{"path": "registry/default/blocks/password-based-auth-nextjs/components/forgot-password-form.tsx",- "content": "'use client'\n\nimport { cn } from '@/lib/utils'\nimport { createClient } from '@/registry/default/clients/nextjs/lib/supabase/client'\nimport { Button } from '@/registry/default/components/ui/button'\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from '@/registry/default/components/ui/card'\nimport { Input } from '@/registry/default/components/ui/input'\nimport { Label } from '@/registry/default/components/ui/label'\nimport Link from 'next/link'\nimport { useState } from 'react'\n\nexport function ForgotPasswordForm({ className, ...props }: React.ComponentPropsWithoutRef<'div'>) {\n const [email, setEmail] = useState('')\n const [error, setError] = useState<string | null>(null)\n const [success, setSuccess] = useState(false)\n const [isLoading, setIsLoading] = useState(false)\n const supabase = createClient()\n\n const handleForgotPassword = async (e: React.FormEvent) => {\n e.preventDefault()\n setIsLoading(true)\n setError(null)\n\n try {\n // The url which will be included in the email. This URL needs to be configured in your redirect URLs in the Supabase dashboard at https://supabase.com/dashboard/project/_/auth/url-configuration\n const { error } = await supabase.auth.resetPasswordForEmail(email, {\n redirectTo: 'http://localhost:3000/update-password',\n })\n if (error) throw error\n setSuccess(true)\n } catch (error: unknown) {\n setError(error instanceof Error ? error.message : 'An error occurred')\n } finally {\n setIsLoading(false)\n }\n }\n\n return (\n <div className={cn('flex flex-col gap-6', className)} {...props}>\n {success ? (\n <Card>\n <CardHeader>\n <CardTitle className=\"text-2xl\">Check Your Email</CardTitle>\n <CardDescription>Password reset instructions sent</CardDescription>\n </CardHeader>\n <CardContent>\n <p className=\"text-sm text-muted-foreground\">\n If you registered using your email and password, you will receive a password reset\n email.\n </p>\n </CardContent>\n </Card>\n ) : (\n <Card>\n <CardHeader>\n <CardTitle className=\"text-2xl\">Reset Your Password</CardTitle>\n <CardDescription>\n Type in your email and we'll send you a link to reset your password\n </CardDescription>\n </CardHeader>\n <CardContent>\n <form onSubmit={handleForgotPassword}>\n <div className=\"flex flex-col gap-6\">\n <div className=\"grid gap-2\">\n <Label htmlFor=\"email\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n placeholder=\"[email protected]\"\n required\n value={email}\n onChange={(e) => setEmail(e.target.value)}\n />\n </div>\n {error && <p className=\"text-sm text-red-500\">{error}</p>}\n <Button type=\"submit\" className=\"w-full\" disabled={isLoading}>\n {isLoading ? 'Sending...' : 'Send reset email'}\n </Button>\n </div>\n <div className=\"mt-4 text-center text-sm\">\n Already have an account?{' '}\n <Link href=\"/login\" className=\"underline underline-offset-4\">\n Login\n </Link>\n </div>\n </form>\n </CardContent>\n </Card>\n )}\n </div>\n )\n}\n",+ "content": "'use client'\n\nimport { cn } from '@/lib/utils'\nimport { createClient } from '@/registry/default/clients/nextjs/lib/supabase/client'\nimport { Button } from '@/registry/default/components/ui/button'\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from '@/registry/default/components/ui/card'\nimport { Input } from '@/registry/default/components/ui/input'\nimport { Label } from '@/registry/default/components/ui/label'\nimport { Link } from '@/registry/default/components/ui/link'\nimport { useState } from 'react'\n\nexport function ForgotPasswordForm({ className, ...props }: React.ComponentPropsWithoutRef<'div'>) {\n const [email, setEmail] = useState('')\n const [error, setError] = useState<string | null>(null)\n const [success, setSuccess] = useState(false)\n const [isLoading, setIsLoading] = useState(false)\n const supabase = createClient()\n\n const handleForgotPassword = async (e: React.FormEvent) => {\n e.preventDefault()\n setIsLoading(true)\n setError(null)\n\n try {\n // The url which will be included in the email. This URL needs to be configured in your redirect URLs in the Supabase dashboard at https://supabase.com/dashboard/project/_/auth/url-configuration\n const { error } = await supabase.auth.resetPasswordForEmail(email, {\n redirectTo: `${window.location.origin}/update-password`,\n })\n if (error) throw error\n setSuccess(true)\n } catch (error: unknown) {\n setError(error instanceof Error ? error.message : 'An error occurred')\n } finally {\n setIsLoading(false)\n }\n }\n\n return (\n <div className={cn('flex flex-col gap-6', className)} {...props}>\n {success ? (\n <Card>\n <CardHeader>\n <CardTitle className=\"text-2xl\">Check Your Email</CardTitle>\n <CardDescription>Password reset instructions sent</CardDescription>\n </CardHeader>\n <CardContent>\n <p className=\"text-sm text-muted-foreground\">\n If you registered using your email and password, you will receive a password reset\n email.\n </p>\n </CardContent>\n </Card>\n ) : (\n <Card>\n <CardHeader>\n <CardTitle className=\"text-2xl\">Reset Your Password</CardTitle>\n <CardDescription>\n Type in your email and we'll send you a link to reset your password\n </CardDescription>\n </CardHeader>\n <CardContent>\n <form onSubmit={handleForgotPassword}>\n <div className=\"flex flex-col gap-6\">\n <div className=\"grid gap-2\">\n <Label htmlFor=\"email\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n placeholder=\"[email protected]\"\n required\n value={email}\n onChange={(e) => setEmail(e.target.value)}\n />\n </div>\n {error && <p className=\"text-sm text-red-500\">{error}</p>}\n <Button type=\"submit\" className=\"w-full\" disabled={isLoading}>\n {isLoading ? 'Sending...' : 'Send reset email'}\n </Button>\n </div>\n <div className=\"mt-4 text-center text-sm\">\n Already have an account?{' '}\n <Link href=\"/login\" className=\"underline underline-offset-4\">\n Login\n </Link>\n </div>\n </form>\n </CardContent>\n </Card>\n )}\n </div>\n )\n}\n","type": "registry:component"},{diff --git a/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/components/forgot-password-form.tsx b/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/components/forgot-password-form.tsxindex e288b984a83..87ca7879499 100644--- a/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/components/forgot-password-form.tsx+++ b/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/components/forgot-password-form.tsx@@ -12,7 +12,7 @@ import {} from '@/registry/default/components/ui/card'import { Input } from '@/registry/default/components/ui/input'import { Label } from '@/registry/default/components/ui/label'-import Link from 'next/link'+import { Link } from '@/registry/default/components/ui/link'import { useState } from 'react'export function ForgotPasswordForm({ className, ...props }: React.ComponentPropsWithoutRef<'div'>) {@@ -30,7 +30,7 @@ export function ForgotPasswordForm({ className, ...props }: React.ComponentPropstry {// The url which will be included in the email. This URL needs to be configured in your redirect URLs in the Supabase dashboard at https://supabase.com/dashboard/project/_/auth/url-configurationconst { error } = await supabase.auth.resetPasswordForEmail(email, {- redirectTo: 'http://localhost:3000/update-password',+ redirectTo: `${window.location.origin}/ui/example/password-based-auth/update-password`,})if (error) throw errorsetSuccess(true)diff --git a/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/components/login-form.tsx b/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/components/login-form.tsxindex eb81206ea2e..4d675b3bef6 100644--- a/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/components/login-form.tsx+++ b/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/components/login-form.tsx@@ -12,7 +12,7 @@ import {} from '@/registry/default/components/ui/card'import { Input } from '@/registry/default/components/ui/input'import { Label } from '@/registry/default/components/ui/label'-import Link from 'next/link'+import { Link } from '@/registry/default/components/ui/link'import { useRouter } from 'next/navigation'import { useState } from 'react'@@ -36,7 +36,7 @@ export function LoginForm({ className, ...props }: React.ComponentPropsWithoutRe})if (error) throw error// Update this route to redirect to an authenticated route. The user already has an active session.- router.push('/protected')+ router.push('/example/password-based-auth/protected')} catch (error: unknown) {setError(error instanceof Error ? error.message : 'An error occurred')} finally {diff --git a/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/components/sign-up-form.tsx b/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/components/sign-up-form.tsxindex 6e231393361..e0a7b1259a8 100644--- a/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/components/sign-up-form.tsx+++ b/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/components/sign-up-form.tsx@@ -12,7 +12,7 @@ import {} from '@/registry/default/components/ui/card'import { Input } from '@/registry/default/components/ui/input'import { Label } from '@/registry/default/components/ui/label'-import Link from 'next/link'+import { Link } from '@/registry/default/components/ui/link'import { useRouter } from 'next/navigation'import { useState } from 'react'@@ -40,9 +40,12 @@ export function SignUpForm({ className, ...props }: React.ComponentPropsWithoutRconst { error } = await supabase.auth.signUp({email,password,+ options: {+ emailRedirectTo: `${window.location.origin}/ui/example/password-based-auth/protected`,+ },})if (error) throw error- router.push('/sign-up-success')+ router.push('/example/password-based-auth/sign-up-success')} catch (error: unknown) {setError(error instanceof Error ? error.message : 'An error occurred')} finally {diff --git a/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/components/update-password-form.tsx b/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/components/update-password-form.tsxindex a0e194a133c..3b68c49ec79 100644--- a/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/components/update-password-form.tsx+++ b/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/components/update-password-form.tsx@@ -31,7 +31,7 @@ export function UpdatePasswordForm({ className, ...props }: React.ComponentPropsconst { error } = await supabase.auth.updateUser({ password })if (error) throw error// Update this route to redirect to an authenticated route. The user already has an active session.- router.push('/protected')+ router.push('/example/password-based-auth/protected')} catch (error: unknown) {setError(error instanceof Error ? error.message : 'An error occurred')} finally {diff --git a/apps/ui-library/registry/default/components/ui/link.tsx b/apps/ui-library/registry/default/components/ui/link.tsxnew file mode 100644index 00000000000..cdac52926b3--- /dev/null+++ b/apps/ui-library/registry/default/components/ui/link.tsx@@ -0,0 +1,11 @@+import { type ComponentPropsWithoutRef } from 'react'+import { cn } from 'ui'++export function Link({ className, href, ...props }: ComponentPropsWithoutRef<'a'>) {+ // A simplified link component for UI Library examples+ // Renders as a regular <a> tag to support iframe base path routing+ // Remove leading slash for relative paths to work with base tag+ const relativeHref = href?.startsWith('/') ? href.slice(1) : href++ return <a {...props} href={relativeHref} className={cn('cursor-pointer', className)} />+}diff --git a/apps/ui-library/registry/default/examples/password-based-auth.tsx b/apps/ui-library/registry/default/examples/password-based-auth.tsxnew file mode 100644index 00000000000..1dbbc662322--- /dev/null+++ b/apps/ui-library/registry/default/examples/password-based-auth.tsx@@ -0,0 +1,13 @@+import { SignUpForm } from '@/registry/default/blocks/password-based-auth-nextjs/components/sign-up-form'++const PasswordBasedAuthDemo = () => {+ return (+ <div className="flex w-full items-center justify-center p-6 md:p-10">+ <div className="w-full max-w-sm">+ <SignUpForm />+ </div>+ </div>+ )+}++export default PasswordBasedAuthDemodiff --git a/apps/ui-library/registry/examples.ts b/apps/ui-library/registry/examples.tsindex 5545e16c97d..a4105724d35 100644--- a/apps/ui-library/registry/examples.ts+++ b/apps/ui-library/registry/examples.ts@@ -23,4 +23,15 @@ export const examples: Registry['items'] = [},],},+ {+ name: 'password-based-auth-demo',+ type: 'registry:example',+ registryDependencies: [],+ files: [+ {+ path: 'registry/default/examples/password-based-auth.tsx',+ type: 'registry:example',+ },+ ],+ },]diff --git a/apps/ui-library/scripts/clean-registry.ts b/apps/ui-library/scripts/clean-registry.tsnew file mode 100644index 00000000000..d9bab9a0e45--- /dev/null+++ b/apps/ui-library/scripts/clean-registry.ts@@ -0,0 +1,55 @@+import * as fs from 'fs'+import * as path from 'path'++function processJsonFile(filePath: string) {+ try {+ // Read the file+ const content = fs.readFileSync(filePath, 'utf8')+ const json = JSON.parse(content)++ // Convert to string to do replacement+ let stringified = JSON.stringify(json, null, 2)++ // Perform the replacement+ stringified = stringified+ .replace(/\/ui\/example\/password-based-auth/g, '')+ .replace(/\/example\/password-based-auth/g, '')+ .replace(+ "import { Link } from '@/registry/default/components/ui/link'",+ "import Link from 'next/link'"+ )++ // Write back to file+ fs.writeFileSync(filePath, stringified)+ console.log(`✓ Updated ${filePath}`)+ } catch (error) {+ console.error(`Error processing ${filePath}:`, error)+ }+}++function processDirectory(directoryPath: string) {+ const files = fs.readdirSync(directoryPath)++ files.forEach((file) => {+ const fullPath = path.join(directoryPath, file)+ const stat = fs.statSync(fullPath)++ if (stat.isDirectory()) {+ processDirectory(fullPath)+ } else if (path.extname(file) === '.json') {+ processJsonFile(fullPath)+ }+ })+}++// Start processing from the specified directory+const targetDir = path.join(process.cwd(), 'public/r')++if (!fs.existsSync(targetDir)) {+ console.error('Target directory does not exist:', targetDir)+ process.exit(1)+}++console.log('Starting JSON file processing...')+processDirectory(targetDir)+console.log('Processing complete!')diff --git a/apps/ui-library/styles/globals.css b/apps/ui-library/styles/globals.cssindex a57423f7310..6055914127f 100644--- a/apps/ui-library/styles/globals.css+++ b/apps/ui-library/styles/globals.css@@ -9,19 +9,74 @@@layer base {:root {+ --background: 0 0% 100%;+ --foreground: 224 71.4% 4.1%;+ --card: 0 0% 100%;+ --card-foreground: 224 71.4% 4.1%;+ --popover: 0 0% 100%;+ --popover-foreground: 224 71.4% 4.1%;+ --primary: 220.9 39.3% 11%;+ --primary-foreground: 210 20% 98%;+ --secondary: 220 14.3% 95.9%;+ --secondary-foreground: 220.9 39.3% 11%;+ --muted: 220 14.3% 95.9%;+ --muted-foreground: 220 8.9% 46.1%;+ --accent: 220 14.3% 95.9%;+ --accent-foreground: 220.9 39.3% 11%;+ --destructive: 0 84.2% 60.2%;+ --destructive-foreground: 0 84.2% 60.2%;+ --border: 220 13% 91%;+ --input: 220 13% 91%;+ --ring: 220 13% 70.8%;--chart-1: 12 76% 61%;--chart-2: 173 58% 39%;--chart-3: 197 37% 24%;--chart-4: 43 74% 66%;--chart-5: 27 87% 67%;+ --radius: 0.625rem;+ --sidebar: 210 20% 98.5%;+ --sidebar-foreground: 224 71.4% 4.1%;+ --sidebar-primary: 220.9 39.3% 11%;+ --sidebar-primary-foreground: 210 20% 98%;+ --sidebar-accent: 220 14.3% 95.9%;+ --sidebar-accent-foreground: 220.9 39.3% 11%;+ --sidebar-border: 220 13% 91%;+ --sidebar-ring: 220 13% 70.8%;}.dark {+ --background: 224 71.4% 4.1%;+ --foreground: 210 20% 98%;+ --card: 224 71.4% 4.1%;+ --card-foreground: 210 20% 98%;+ --popover: 224 71.4% 4.1%;+ --popover-foreground: 210 20% 98%;+ --primary: 210 20% 98%;+ --primary-foreground: 220.9 39.3% 11%;+ --secondary: 215 27.9% 16.9%;+ --secondary-foreground: 210 20% 98%;+ --muted: 215 27.9% 16.9%;+ --muted-foreground: 217.9 10.6% 64.9%;+ --accent: 215 27.9% 16.9%;+ --accent-foreground: 210 20% 98%;+ --destructive: 0 62.8% 30.6%;+ --destructive-foreground: 0 84.2% 60.2%;+ --border: 215 27.9% 16.9%;+ --input: 215 27.9% 16.9%;+ --ring: 217.9 10.6% 55.6%;--chart-1: 220 70% 50%;--chart-2: 160 60% 45%;--chart-3: 30 80% 55%;--chart-4: 280 65% 60%;--chart-5: 340 75% 55%;+ --sidebar: 220.9 39.3% 11%;+ --sidebar-foreground: 210 20% 98%;+ --sidebar-primary: 220 70% 50%;+ --sidebar-primary-foreground: 210 20% 98%;+ --sidebar-accent: 215 27.9% 16.9%;+ --sidebar-accent-foreground: 210 20% 98%;+ --sidebar-border: 215 27.9% 16.9%;+ --sidebar-ring: 220 13% 43.9%;}}@@ -68,58 +123,75 @@}.preview {- --background: hsl(0 0% 100%);- --foreground: hsl(224 71.4% 4.1%);- --card: hsl(0 0% 100%);- --card-foreground: hsl(224 71.4% 4.1%);- --popover: hsl(0 0% 100%);- --popover-foreground: hsl(224 71.4% 4.1%);- --primary: hsl(220.9 39.3% 11%);- --primary-foreground: hsl(210 20% 98%);- --secondary: hsl(220 14.3% 95.9%);- --secondary-foreground: hsl(220.9 39.3% 11%);- --muted: hsl(220 14.3% 95.9%);- --muted-foreground: hsl(220 8.9% 46.1%);- --accent: hsl(220 14.3% 95.9%);- --accent-foreground: hsl(220.9 39.3% 11%);- --destructive: hsl(0 84.2% 60.2%);- --destructive-foreground: hsl(210 20% 98%);- --border: hsl(220 13% 91%);- --input: hsl(220 13% 91%);- --ring: hsl(224 71.4% 4.1%);- --chart-1: hsl(12 76% 61%);- --chart-2: hsl(173 58% 39%);- --chart-3: hsl(197 37% 24%);- --chart-4: hsl(43 74% 66%);- --chart-5: hsl(27 87% 67%);- --radius: 0.6rem;+ --background: 0 0% 100%;+ --foreground: 0 0% 14.5%;+ --card: 0 0% 100%;+ --card-foreground: 0 0% 14.5%;+ --popover: 0 0% 100%;+ --popover-foreground: 0 0% 14.5%;+ --primary: 0 0% 20.5%;+ --primary-foreground: 0 0% 98.5%;+ --secondary: 0 0% 97%;+ --secondary-foreground: 0 0% 20.5%;+ --muted: 0 0% 97%;+ --muted-foreground: 0 0% 55.6%;+ --accent: 0 0% 97%;+ --accent-foreground: 0 0% 20.5%;+ --destructive: 27.3 24.5% 57.7%;+ --destructive-foreground: 27.3 24.5% 57.7%;+ --border: 0 0% 92.2%;+ --input: 0 0% 92.2%;+ --ring: 0 0% 70.8%;+ --chart-1: 41.1 22.2% 64.6%;+ --chart-2: 184.7 11.8% 60%;+ --chart-3: 227.4 7% 39.8%;+ --chart-4: 84.4 18.9% 82.8%;+ --chart-5: 70.1 18.8% 76.9%;+ --radius: 0.625rem;+ --sidebar: 0 0% 98.5%;+ --sidebar-foreground: 0 0% 14.5%;+ --sidebar-primary: 0 0% 20.5%;+ --sidebar-primary-foreground: 0 0% 98.5%;+ --sidebar-accent: 0 0% 97%;+ --sidebar-accent-foreground: 0 0% 20.5%;+ --sidebar-border: 0 0% 92.2%;+ --sidebar-ring: 0 0% 70.8%;}-.dark .preview {- --background: hsl(224 71.4% 4.1%);- --foreground: hsl(210 20% 98%);- --card: hsl(224 71.4% 4.1%);- --card-foreground: hsl(210 20% 98%);- --popover: hsl(224 71.4% 4.1%);- --popover-foreground: hsl(210 20% 98%);- --primary: hsl(210 20% 98%);- --primary-foreground: hsl(220.9 39.3% 11%);- --secondary: hsl(215 27.9% 16.9%);- --secondary-foreground: hsl(210 20% 98%);- --muted: hsl(215 27.9% 16.9%);- --muted-foreground: hsl(217.9 10.6% 64.9%);- --accent: hsl(215 27.9% 16.9%);- --accent-foreground: hsl(210 20% 98%);- --destructive: hsl(0 62.8% 30.6%);- --destructive-foreground: hsl(210 20% 98%);- --border: hsl(215 27.9% 16.9%);- --input: hsl(215 27.9% 16.9%);- --ring: hsl(216 12.2% 83.9%);- --chart-1: hsl(220 70% 50%);- --chart-2: hsl(160 60% 45%);- --chart-3: hsl(30 80% 55%);- --chart-4: hsl(280 65% 60%);- --chart-5: hsl(340 75% 55%);+[data-theme='dark'] .preview,+[data-theme='classic-dark'] .preview {+ --background: 0 0% 14.5%;+ --foreground: 0 0% 98.5%;+ --card: 0 0% 0%;+ --card-foreground: 0 0% 98.5%;+ --popover: 0 0% 14.5%;+ --popover-foreground: 0 0% 98.5%;+ --primary: 0 0% 98.5%;+ --primary-foreground: 0 0% 20.5%;+ --secondary: 0 0% 26.9%;+ --secondary-foreground: 0 0% 98.5%;+ --muted: 0 0% 26.9%;+ --muted-foreground: 0 0% 70.8%;+ --accent: 0 0% 26.9%;+ --accent-foreground: 0 0% 98.5%;+ --destructive: 25.7 14.1% 39.6%;+ --destructive-foreground: 25.3 23.7% 63.7%;+ --border: 0 0% 26.9%;+ --input: 0 0% 26.9%;+ --ring: 0 0% 55.6%;+ --chart-1: 264.4 24.3% 48.8%;+ --chart-2: 162.5 17% 69.6%;+ --chart-3: 70.1 18.8% 76.9%;+ --chart-4: 303.9 26.5% 62.7%;+ --chart-5: 16.4 24.6% 64.5%;+ --sidebar: 0 0% 20.5%;+ --sidebar-foreground: 0 0% 98.5%;+ --sidebar-primary: 264.4 24.3% 48.8%;+ --sidebar-primary-foreground: 0 0% 98.5%;+ --sidebar-accent: 0 0% 26.9%;+ --sidebar-accent-foreground: 0 0% 98.5%;+ --sidebar-border: 0 0% 26.9%;+ --sidebar-ring: 0 0% 43.9%;}.preview * {