Platform Kit for Nextjs and Supabase
supabase-library/platform-kit-nextjsFreeBlock
Platform Kit for Nextjs and Supabase
Install it
npx shadcn@latest add https://raw.githubusercontent.com/supabase/supabase/master/apps/ui-library/public/r/platform-kit-nextjs.jsonSource
1'use client'23import { zodResolver } from '@hookform/resolvers/zod'4import { useEffect, useRef } from 'react'5import { useForm } from 'react-hook-form'6import type { z, ZodTypeAny } from 'zod'78import { Button } from '@/registry/default/components/ui/button'9import {10 Form,11 FormControl,12 FormDescription,13 FormField,14 FormItem,15 FormLabel,16 FormMessage,17} from '@/registry/default/components/ui/form'18import { Input } from '@/registry/default/components/ui/input'19import {20 Select,21 SelectContent,22 SelectItem,23 SelectTrigger,24 SelectValue,25} from '@/registry/default/components/ui/select'26import { Switch } from '@/registry/default/components/ui/switch'2728interface DynamicFormProps<T extends z.ZodRawShape = z.ZodRawShape> {29 schema: z.ZodObject<T>30 onSubmit: (data: z.infer<z.ZodObject<T>>) => void31 isLoading?: boolean32 initialValues?: Partial<z.infer<z.ZodObject<T>>>33 labels?: Record<string, string | { label: string; options?: Record<string, string> }>34 columnInfo?: Record<string, { data_type: string; is_nullable: boolean }>35}3637const getZodDef = (schema: ZodTypeAny): Record<string, any> =>38 (schema as any)._def || (schema as any).def3940const unwrapZodType = (fieldSchema: ZodTypeAny): ZodTypeAny => {41 if (42 !fieldSchema ||43 typeof getZodDef(fieldSchema) !== 'object' ||44 getZodDef(fieldSchema) === null45 ) {46 throw new Error(47 `unwrapZodType received an invalid Zod schema object. Check the console for the problematic schema/key.`48 )49 }50 let currentSchema = fieldSchema5152 // Support both old (typeName) and new (type) Zod formats53 const getTypeName = (def: Record<string, any>) => def.typeName || def.type5455 while (56 getTypeName(getZodDef(currentSchema)) === 'ZodOptional' ||57 getTypeName(getZodDef(currentSchema)) === 'optional' ||58 getTypeName(getZodDef(currentSchema)) === 'ZodDefault' ||59 getTypeName(getZodDef(currentSchema)) === 'default' ||60 getTypeName(getZodDef(currentSchema)) === 'ZodNullable' ||61 getTypeName(getZodDef(currentSchema)) === 'nullable' ||62 getTypeName(getZodDef(currentSchema)) === 'ZodEffects' ||63 getTypeName(getZodDef(currentSchema)) === 'effects'64 ) {65 const typeName = getTypeName(getZodDef(currentSchema))66 if (typeName === 'ZodEffects' || typeName === 'effects') {67 // For ZodEffects, get the schema inside the effect68 currentSchema = getZodDef(currentSchema).schema69 } else {70 currentSchema = getZodDef(currentSchema).innerType71 }72 }73// … truncated
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 |
