Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Connect sheet content structure (#42373)

Saxon Fletcherb9a09d861294
diff --git a/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx b/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx
index 0f7db86b186..8907cca134b 100644
--- a/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx
+++ b/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx
@@ -18,33 +18,33 @@ import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'
import {
Badge,
Button,
+ cn,
CodeBlock,
+ Collapsible_Shadcn_,
CollapsibleContent_Shadcn_,
CollapsibleTrigger_Shadcn_,
- Collapsible_Shadcn_,
DIALOG_PADDING_X,
+ Select_Shadcn_,
SelectContent_Shadcn_,
SelectItem_Shadcn_,
SelectTrigger_Shadcn_,
SelectValue_Shadcn_,
- Select_Shadcn_,
Separator,
- cn,
} from 'ui'
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
import {
CONNECTION_PARAMETERS,
- type ConnectionStringMethod,
+ connectionStringMethodOptions,
DATABASE_CONNECTION_TYPES,
DatabaseConnectionType,
IPV4_ADDON_TEXT,
PGBOUNCER_ENABLED_BUT_NO_IPV4_ADDON_TEXT,
- connectionStringMethodOptions,
+ type ConnectionStringMethod,
} from './Connect.constants'
import { CodeBlockFileHeader, ConnectionPanel } from './ConnectionPanel'
import { getConnectionStrings } from './DatabaseSettings.utils'
-import examples, { Example } from './DirectConnectionExamples'
+import { examples, type Example } from './DirectConnectionExamples'
const StepLabel = ({
number,
diff --git a/apps/studio/components/interfaces/Connect/DirectConnectionExamples.tsx b/apps/studio/components/interfaces/Connect/DirectConnectionExamples.tsx
index 80084d1337d..fb3b6c06c6c 100644
--- a/apps/studio/components/interfaces/Connect/DirectConnectionExamples.tsx
+++ b/apps/studio/components/interfaces/Connect/DirectConnectionExamples.tsx
@@ -7,7 +7,7 @@ export type Example = {
}[]
}
-const examples = {
+export const examples = {
nodejs: {
installCommands: ['npm install postgres'],
files: [
@@ -149,5 +149,3 @@ except Exception as e:
],
},
}
-
-export default examples
diff --git a/apps/studio/components/interfaces/Connect/content/nextjs/pages/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/nextjs/pages/supabasejs/content.tsx
index 92a3ea50e64..29d4bea895b 100644
--- a/apps/studio/components/interfaces/Connect/content/nextjs/pages/supabasejs/content.tsx
+++ b/apps/studio/components/interfaces/Connect/content/nextjs/pages/supabasejs/content.tsx
@@ -1,12 +1,11 @@
import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'
-
-import { SimpleCodeBlock } from 'ui'
import {
ConnectTabContent,
ConnectTabs,
ConnectTabTrigger,
ConnectTabTriggers,
} from 'components/interfaces/Connect/ConnectTabs'
+import { SimpleCodeBlock } from 'ui'
const ContentFile = ({ projectKeys }: ContentFileProps) => {
return (
@@ -53,7 +52,7 @@ function Page() {
const [todos, setTodos] = useState([])
useEffect(() => {
- function getTodos() {
+ async function getTodos() {
const { data: todos } = await supabase.from('todos').select()
if (todos.length > 1) {
diff --git a/apps/studio/components/interfaces/ConnectSheet/Connect.constants.ts b/apps/studio/components/interfaces/ConnectSheet/Connect.constants.ts
new file mode 100644
index 00000000000..ed6c00599a7
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/Connect.constants.ts
@@ -0,0 +1,421 @@
+import { DOCS_URL } from 'lib/constants'
+import { CodeBlockLang } from 'ui'
+
+export type DatabaseConnectionType =
+ | 'uri'
+ | 'psql'
+ | 'golang'
+ | 'jdbc'
+ | 'dotnet'
+ | 'nodejs'
+ | 'php'
+ | 'python'
+ | 'sqlalchemy'
+
+export const INSTALL_COMMANDS: Record<string, string> = {
+ supabasejs: 'npm install @supabase/supabase-js',
+ supabasepy: 'pip install supabase',
+ supabaseflutter: 'flutter pub add supabase_flutter',
+ supabaseswift:
+ 'swift package add-dependency https://github.com/supabase-community/supabase-swift',
+ supabasekt: 'implementation("io.github.jan-tennert.supabase:supabase-kt:VERSION")',
+}
+
+export const DATABASE_CONNECTION_TYPES: {
+ id: DatabaseConnectionType
+ label: string
+ contentType: 'input' | 'code'
+ lang: CodeBlockLang
+ fileTitle: string | undefined
+}[] = [
+ { id: 'uri', label: 'URI', contentType: 'input', lang: 'bash', fileTitle: undefined },
+ { id: 'psql', label: 'PSQL', contentType: 'code', lang: 'bash', fileTitle: undefined },
+ { id: 'golang', label: 'Golang', contentType: 'code', lang: 'go', fileTitle: '.env' },
+ { id: 'jdbc', label: 'JDBC', contentType: 'input', lang: 'bash', fileTitle: undefined },
+ {
+ id: 'dotnet',
+ label: '.NET',
+ contentType: 'code',
+ lang: 'csharp',
+ fileTitle: 'appsettings.json',
+ },
+ { id: 'nodejs', label: 'Node.js', contentType: 'code', lang: 'js', fileTitle: '.env' },
+ { id: 'php', label: 'PHP', contentType: 'code', lang: 'php', fileTitle: '.env' },
+ { id: 'python', label: 'Python', contentType: 'code', lang: 'python', fileTitle: '.env' },
+ { id: 'sqlalchemy', label: 'SQLAlchemy', contentType: 'code', lang: 'python', fileTitle: '.env' },
+]
+
+export const CONNECTION_PARAMETERS = {
+ host: {
+ key: 'host',
+ description: 'The hostname of your database',
+ },
+ port: {
+ key: 'port',
+ description: 'Port number for the connection',
+ },
+ database: {
+ key: 'database',
+ description: 'Default database name',
+ },
+ user: {
+ key: 'user',
+ description: 'Database user',
+ },
+ pool_mode: {
+ key: 'pool_mode',
+ description: 'Connection pooling behavior',
+ },
+} as const
+
+export type ConnectionType = {
+ key: string
+ icon: string
+ label: string
+ guideLink?: string
+ children: ConnectionType[]
+ files?: {
+ name: string
+ content: string
+ }[]
+}
+
+export const FRAMEWORKS: ConnectionType[] = [
+ {
+ key: 'nextjs',
+ label: 'Next.js',
+ icon: 'nextjs',
+ guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/nextjs`,
+ children: [
+ {
+ key: 'app',
+ label: 'App Router',
+ icon: '',
+ children: [
+ {
+ key: 'supabasejs',
+ label: 'supabase-js',
+ icon: 'supabase',
+ children: [],
+ },
+ ],
+ },
+ {
+ key: 'pages',
+ label: 'Pages Router',
+ icon: '',
+ children: [
+ {
+ key: 'supabasejs',
+ label: 'Supabase-js',
+ children: [],
+ icon: 'supabase',
+ },
+ ],
+ },
+ ],
+ },
+ {
+ key: 'remix',
+ label: 'Remix',
+ icon: 'remix',
+ guideLink: `${DOCS_URL}/guides/auth/server-side/creating-a-client?framework=remix&environment=remix-loader`,
+ children: [
+ {
+ key: 'supabasejs',
+ label: 'Supabase-js',
+ children: [],
+ icon: 'supabase',
+ },
+ ],
+ },
+ {
+ key: 'react',
+ label: 'React',
+ icon: 'react',
+ guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/reactjs`,
+ children: [
+ {
+ key: 'vite',
+ label: 'Vite',
+ icon: 'vite',
+ children: [
+ {
+ key: 'supabasejs',
+ label: 'Supabase-js',
+ children: [],
+ icon: 'supabase',
+ },
+ ],
+ },
+ {
+ key: 'create-react-app',
+ label: 'Create React App',
+ icon: 'react',
+ children: [
+ {
+ key: 'supabasejs',
+ label: 'supabase-js',
+ icon: 'supabase',
+ children: [],
+ },
+ ],
+ },
+ ],
+ },
+ {
+ key: 'nuxt',
+ label: 'Nuxt',
+ icon: 'nuxt',
+ guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/nuxtjs`,
+ children: [
+ {
+ key: 'supabasejs',
+ label: 'Supabase-js',
+ children: [],
+ icon: 'supabase',
+ },
+ ],
+ },
+ {
+ key: 'vuejs',
+ label: 'Vue.JS',
+ icon: 'vuejs',
+ guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/vue`,
+ children: [
+ {
+ key: 'supabasejs',
+ label: 'Supabase-js',
+ children: [],
+ icon: 'supabase',
+ },
+ ],
+ },
+
+ {
+ key: 'sveltekit',
+ label: 'SvelteKit',
+ icon: 'sveltekit',
+ guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/sveltekit`,
+ children: [
+ {
+ key: 'supabasejs',
+ label: 'Supabase-js',
+ children: [],
+ icon: 'supabase',
+ },
+ ],
+ },
+ {
+ key: 'solidjs',
+ label: 'Solid.js',
+ icon: 'solidjs',
+ guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/solidjs`,
+ children: [
+ {
+ key: 'supabasejs',
+ label: 'Supabase-js',
+ children: [],
+ icon: 'supabase',
+ },
+ ],
+ },
+ {
+ key: 'astro',
+ label: 'Astro',
+ icon: 'astro',
+ guideLink: 'https://docs.astro.build/en/guides/backend/supabase/',
+ children: [
+ {
+ key: 'supabasejs',
+ label: 'Supabase-js',
+ children: [],
+ icon: 'supabase',
+ },
+ ],
+ },
+ {
+ key: 'refine',
+ label: 'Refine',
+ icon: 'refine',
+ guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/refine`,
+ children: [
+ {
+ key: 'supabasejs',
+ label: 'Supabase-js',
+ children: [],
+ icon: 'supabase',
+ },
+ ],
+ },
+ {
+ key: 'tanstack',
+ label: 'TanStack Start',
+ icon: 'tanstack',
+ guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/tanstack`,
+ children: [
+ {
+ key: 'supabasejs',
+ label: 'Supabase-js',
+ children: [],
+ icon: 'supabase',
+ },
+ ],
+ },
+ {
+ key: 'flask',
+ label: 'Flask (Python)',
+ icon: 'python',
+ guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/flask`,
+ children: [
+ {
+ key: 'supabasepy',
+ label: 'supabase-py',
+ children: [],
+ icon: 'supabase',
+ },
+ ],
+ },
+]
+
+export const MOBILES: ConnectionType[] = [
+ {
+ key: 'exporeactnative',
+ label: 'Expo React Native',
+ icon: 'expo',
+ guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/expo-react-native`,
+ children: [
+ {
+ key: 'supabasejs',
+ label: 'Supabase-js',
+ children: [],
+ icon: 'supabase',
+ },
+ ],
+ },
+ {
+ key: 'flutter',
+ label: 'Flutter',
+ icon: 'flutter',
+ guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-flutter`,
+ children: [
+ {
+ key: 'supabaseflutter',
+ label: 'supabase-flutter',
+ children: [],
+ icon: 'supabase',
+ },
+ ],
+ },
+ {
+ key: 'ionicreact',
+ label: 'Ionic React',
+ icon: 'react',
+ guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-ionic-react`,
+ children: [
+ {
+ key: 'supabasejs',
+ label: 'Supabase-js',
+ children: [],
+ icon: 'supabase',
+ },
+ ],
+ },
+ {
+ key: 'swift',
+ label: 'Swift',
+ icon: 'swift',
+ guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-swift`,
+ children: [
+ {
+ key: 'supabaseswift',
+ label: 'supabase-swift',
+ children: [],
+ icon: 'supabase',
+ },
+ ],
+ },
+ {
+ key: 'androidkotlin',
+ label: 'Android Kotlin',
+ icon: 'kotlin',
+ guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-kotlin`,
+ children: [
+ {
+ key: 'supabasekt',
+ label: 'supabase-kt',
+ children: [],
+ icon: 'supabase',
+ },
+ ],
+ },
+ {
+ key: 'ionicangular',
+ label: 'Ionic Angular',
+ icon: 'ionic-angular',
+ guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-ionic-angular`,
+ children: [
+ {
+ key: 'supabasejs',
+ label: 'Supabase-js',
+ children: [],
+ icon: 'supabase',
+ },
+ ],
+ },
+]
+
+export const ORMS: ConnectionType[] = [
+ {
+ key: 'prisma',
+ label: 'Prisma',
+ icon: 'prisma',
+ guideLink: 'https://supabase.com/partners/integrations/prisma',
+ children: [],
+ },
+ {
+ key: 'drizzle',
+ label: 'Drizzle',
+ icon: 'drizzle',
+ guideLink: `${DOCS_URL}/guides/database/connecting-to-postgres#connecting-with-drizzle`,
+ children: [],
+ },
+]
+
+export const CONNECTION_TYPES = [
+ { key: 'direct', label: 'Connection String', obj: [] },
+ { key: 'frameworks', label: 'App Frameworks', obj: FRAMEWORKS },
+ { key: 'mobiles', label: 'Mobile Frameworks', obj: MOBILES },
+ { key: 'orms', label: 'ORMs', obj: ORMS },
+ { key: 'mcp', label: 'MCP', obj: [] },
+]
+
+export const PGBOUNCER_ENABLED_BUT_NO_IPV4_ADDON_TEXT =
+ 'Purchase IPv4 add-on or use Shared Pooler if on a IPv4 network'
+export const IPV4_ADDON_TEXT = 'Connections are IPv4 proxied with IPv4 add-on'
+
+export type ConnectionStringMethod = 'direct' | 'transaction' | 'session'
+
+export const connectionStringMethodOptions: Record<
+ ConnectionStringMethod,
+ { value: string; label: string; description: string }
+> = {
+ direct: {
+ value: 'direct',
+ label: 'Direct connection',
+ description:
+ 'Ideal for applications with persistent and long-lived connections, such as those running on virtual machines or long-standing containers.',
+ },
+ transaction: {
+ value: 'transaction',
+ label: 'Transaction pooler',
+ description:
+ 'Ideal for stateless applications like serverless functions where each interaction with Postgres is brief and isolated.',
+ },
+ session: {
+ value: 'session',
+ label: 'Session pooler',
+ description:
+ 'Only recommended as an alternative to Direct Connection, when connecting via an IPv4 network.',
+ },
+}
diff --git a/apps/studio/components/interfaces/ConnectSheet/Connect.types.ts b/apps/studio/components/interfaces/ConnectSheet/Connect.types.ts
new file mode 100644
index 00000000000..929208032dd
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/Connect.types.ts
@@ -0,0 +1,149 @@
+// ============================================================================
+// Project Keys (existing)
+// ============================================================================
+
+export type ProjectKeys = {
+ apiUrl: string | null
+ anonKey: string | null
+ publishableKey: string | null
+}
+
+// ============================================================================
+// Connection Strings
+// ============================================================================
+
+export interface ConnectionStringPooler {
+ transactionShared: string
+ sessionShared: string
+ transactionDedicated?: string
+ sessionDedicated?: string
+ ipv4SupportedForDedicatedPooler: boolean
+ direct?: string
+}
+
+// ============================================================================
+// Schema Types - Conditional Resolution
+// ============================================================================
+
+/**
+ * A value that can be resolved conditionally based on state.
+ * Resolution walks the tree using state values, falling back to DEFAULT.
+ *
+ * Example:
+ * {
+ * framework: {
+ * nextjs: 'NextJsContent',
+ * react: 'ReactContent',
+ * DEFAULT: 'GenericFrameworkContent'
+ * },
+ * direct: 'DirectContent',
+ * DEFAULT: null
+ * }
+ */
+export type ConditionalValue<T> =
+ | T
+ | {
+ [stateValue: string]: ConditionalValue<T> | undefined
+ DEFAULT?: T
+ }
+
+// ============================================================================
+// Schema Types - Modes
+// ============================================================================
+
+type ConnectMode = string
+
+// ============================================================================
+// Schema Types - Fields
+// ============================================================================
+
+type FieldType = 'select' | 'radio-grid' | 'radio-list' | 'switch' | 'multi-select'
+
+export interface FieldOption {
+ value: string
+ label: string
+ icon?: string
+ description?: string
+}
+
+type FieldOptionsResolver = (state: ConnectState) => FieldOption[]
+
+interface FieldDefinition {
+ id: string
+ type: FieldType
+ label: string
+ description?: string
+ // Options can be static, conditional, or resolved from state
+ options?: FieldOption[] | ConditionalValue<FieldOption[]> | FieldOptionsResolver
+ // Only show this field when these state conditions are met
+ dependsOn?: Record<string, string[]>
+ // Default value for this field
+ defaultValue?: string | boolean | string[]
+}
+
+// ============================================================================
+// Schema Types - Steps
+// ============================================================================
+
+export interface StepDefinition {
+ id: string
+ title: string
+ description: string
+ // Component identifier or content file path, can be conditional
+ content: ConditionalValue<string | null>
+}
+
+export type StepTree =
+ | StepDefinition[]
+ | {
+ [fieldId: string]: StepFieldValueMap
+ }
+
+export type StepFieldValueMap = {
+ [fieldValue: string]: StepTree | undefined
+ DEFAULT?: StepTree
+}
+
+// ============================================================================
+// Schema Types - Main Schema
+// ============================================================================
+
+export interface ConnectSchema {
+ fields: Record<string, FieldDefinition>
+ // Steps are fully conditional based on state
+ steps: StepTree
+}
+
+// ============================================================================
+// State Types
+// ============================================================================
+
+export interface ConnectState {
+ mode: ConnectMode
+ [fieldId: string]: string | boolean | string[]
+}
+
+export interface ResolvedStep {
+ id: string
+ title: string
+ description: string
+ content: string // Resolved component identifier
+}
+
+export interface ResolvedField extends FieldDefinition {
+ resolvedOptions: FieldOption[]
+}
+
+// ============================================================================
+// Step Content Props - Unified props for all step content components
+// ============================================================================
+
+/**
+ * Props passed to all step content components.
+ * Components receive full state and can conditionally render whatever they need.
+ */
+export interface StepContentProps {
+ state: ConnectState
+ projectKeys: ProjectKeys
+ connectionStringPooler: ConnectionStringPooler
+}
diff --git a/apps/studio/components/interfaces/ConnectSheet/ConnectConfigSection.tsx b/apps/studio/components/interfaces/ConnectSheet/ConnectConfigSection.tsx
new file mode 100644
index 00000000000..5219d1474bb
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/ConnectConfigSection.tsx
@@ -0,0 +1,216 @@
+import {
+ RadioGroupStacked,
+ RadioGroupStackedItem,
+ Select_Shadcn_,
+ SelectContent_Shadcn_,
+ SelectItem_Shadcn_,
+ SelectTrigger_Shadcn_,
+ SelectValue_Shadcn_,
+ Switch,
+} from 'ui'
+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
+import {
+ MultiSelector,
+ MultiSelectorContent,
+ MultiSelectorItem,
+ MultiSelectorList,
+ MultiSelectorTrigger,
+} from 'ui-patterns/multi-select'
+
+import type { FieldOption, ResolvedField } from './Connect.types'
+import { ConnectionIcon } from './ConnectionIcon'
+
+interface ConnectConfigSectionProps {
+ activeFields: ResolvedField[]
+ state: Record<string, string | boolean | string[]>
+ onFieldChange: (fieldId: string, value: string | boolean | string[]) => void
+ getFieldOptions: (fieldId: string) => FieldOption[]
+}
+
+export function ConnectConfigSection({
+ activeFields,
+ state,
+ onFieldChange,
+ getFieldOptions,
+}: ConnectConfigSectionProps) {
+ if (activeFields.length === 0) return null
+
+ const formLayoutClassName = 'md:[&>div:first-child]:!w-1/3 xl:[&>div:first-child]:!w-2/5'
+
+ return (
+ <div className="flex flex-col gap-y-4">
+ {activeFields.map((field) => {
+ const options = getFieldOptions(field.id)
+ const value = state[field.id]
+
+ // Skip fields with no options (or single option that's auto-selected)
+ // Exception: switch and multi-select fields don't require options
+ if (field.type !== 'switch' && field.type !== 'multi-select') {
+ if (options.length === 0) return null
+ if (options.length === 1) return null
+ }
+
+ switch (field.type) {
+ case 'radio-grid':
+ return (
+ <FormItemLayout
+ key={field.id}
+ isReactForm={false}
+ layout="flex-row-reverse"
+ label={field.label}
+ className={formLayoutClassName}
+ >
+ <RadioGroupStacked
+ value={String(value ?? '')}
+ onValueChange={(v) => onFieldChange(field.id, v)}
+ className="flex-row gap-3 space-y-0"
+ >
+ {options.map((option) => (
+ <RadioGroupStackedItem
+ key={option.value}
+ id={`connect-${field.id}-${option.value}`}
+ value={option.value}
+ label=""
+ className="flex-1 rounded-lg text-left"
+ >
+ <div className="flex items-center gap-2">
+ {option.icon && <ConnectionIcon icon={option.icon} />}
+ <span className="text-sm">{option.label}</span>
+ </div>
+ </RadioGroupStackedItem>
+ ))}
+ </RadioGroupStacked>
+ </FormItemLayout>
+ )
+
+ case 'radio-list':
+ return (
+ <FormItemLayout
+ key={field.id}
+ isReactForm={false}
+ layout="flex-row-reverse"
+ label={field.label}
+ className={formLayoutClassName}
+ >
+ <RadioGroupStacked
+ value={String(value ?? '')}
+ onValueChange={(v) => onFieldChange(field.id, v)}
+ >
+ {options.map((option) => (
+ <RadioGroupStackedItem
+ key={option.value}
+ id={`connect-${field.id}-${option.value}`}
+ value={option.value}
+ label=""
+ className="w-full text-left"
+ >
+ <div className="flex flex-col gap-0.5">
+ <div className="flex items-center gap-2">
+ {option.icon && <ConnectionIcon icon={option.icon} />}
+ <span className="text-sm">{option.label}</span>
+ </div>
+ {option.description && (
+ <span className="text-sm text-foreground-lighter">
+ {option.description}
+ </span>
+ )}
+ </div>
+ </RadioGroupStackedItem>
+ ))}
+ </RadioGroupStacked>
+ </FormItemLayout>
+ )
+
+ case 'select':
+ return (
+ <FormItemLayout
+ key={field.id}
+ isReactForm={false}
+ layout="flex-row-reverse"
+ label={field.label}
+ description={field.description}
+ className={formLayoutClassName}
+ >
+ <Select_Shadcn_
+ value={String(value ?? '')}
+ onValueChange={(v) => onFieldChange(field.id, v)}
+ >
+ <SelectTrigger_Shadcn_ size="small" className="w-full">
+ <SelectValue_Shadcn_ />
+ </SelectTrigger_Shadcn_>
+ <SelectContent_Shadcn_>
+ {options.map((option) => (
+ <SelectItem_Shadcn_ key={option.value} value={option.value}>
+ {option.label}
+ </SelectItem_Shadcn_>
+ ))}
+ </SelectContent_Shadcn_>
+ </Select_Shadcn_>
+ </FormItemLayout>
+ )
+
+ case 'switch':
+ return (
+ <FormItemLayout
+ key={field.id}
+ isReactForm={false}
+ layout="flex-row-reverse"
+ label={field.label}
+ description={field.description}
+ className={formLayoutClassName}
+ >
+ <Switch
+ id={field.id}
+ checked={Boolean(value)}
+ onCheckedChange={(v) => onFieldChange(field.id, v)}
+ />
+ </FormItemLayout>
+ )
+
+ case 'multi-select':
+ return (
+ <FormItemLayout
+ key={field.id}
+ isReactForm={false}
+ layout="flex-row-reverse"
+ label={field.label}
+ description={field.description}
+ className={formLayoutClassName}
+ >
+ <MultiSelector
+ values={Array.isArray(value) ? value : []}
+ onValuesChange={(v) => onFieldChange(field.id, v)}
+ >
+ <MultiSelectorTrigger
+ className="w-full"
+ label="All features except Storage enabled by default"
+ badgeLimit="wrap"
+ showIcon={true}
+ />
+ <MultiSelectorContent>
+ <MultiSelectorList>
+ {options.map((option) => (
+ <MultiSelectorItem key={option.value} value={option.value}>
+ <div className="flex flex-col">
+ <span className="font-medium">{option.label}</span>
+ {option.description && (
+ <span className="text-xs text-foreground-light">
+ {option.description}
+ </span>
+ )}
+ </div>
+ </MultiSelectorItem>
+ ))}
+ </MultiSelectorList>
+ </MultiSelectorContent>
+ </MultiSelector>
+ </FormItemLayout>
+ )
+
+ default:
+ return null
+ }
+ })}
+ </div>
+ )
+}
diff --git a/apps/studio/components/interfaces/ConnectSheet/ConnectSheet.tsx b/apps/studio/components/interfaces/ConnectSheet/ConnectSheet.tsx
index 737be71a55d..20905f90f42 100644
--- a/apps/studio/components/interfaces/ConnectSheet/ConnectSheet.tsx
+++ b/apps/studio/components/interfaces/ConnectSheet/ConnectSheet.tsx
@@ -1,5 +1,16 @@
+import { PermissionAction } from '@supabase/shared-types/out/constants'
+import { useParams } from 'common'
+import { getKeys, useAPIKeysQuery } from 'data/api-keys/api-keys-query'
+import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query'
+import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
import { parseAsBoolean, parseAsString, useQueryState } from 'nuqs'
-import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, cn } from 'ui'
+import { useMemo } from 'react'
+import { cn, Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from 'ui'
+
+import type { ProjectKeys } from './Connect.types'
+import { ConnectConfigSection } from './ConnectConfigSection'
+import { ConnectStepsSection } from './ConnectStepsSection'
+import { useConnectState } from './useConnectState'
export const ConnectSheet = () => {
const [showConnect, setShowConnect] = useQueryState(
@@ -15,21 +26,57 @@ export const ConnectSheet = () => {
setShowConnect(sheetOpen)
}
+ const { state, updateField, activeFields, resolvedSteps, getFieldOptions } = useConnectState()
+
+ // Project keys for step components
+ const { ref: projectRef } = useParams()
+ const { data: settings } = useProjectSettingsV2Query({ projectRef }, { enabled: showConnect })
+ const { can: canReadAPIKeys } = useAsyncCheckPermissions(
+ PermissionAction.READ,
+ 'service_api_keys'
+ )
+ const { data: apiKeys } = useAPIKeysQuery({ projectRef }, { enabled: canReadAPIKeys })
+ const { anonKey, publishableKey } = canReadAPIKeys
+ ? getKeys(apiKeys)
+ : { anonKey: null, publishableKey: null }
+
+ const projectKeys: ProjectKeys = useMemo(() => {
+ const protocol = settings?.app_config?.protocol ?? 'https'
+ const endpoint = settings?.app_config?.endpoint ?? ''
+ const apiHost = canReadAPIKeys ? `${protocol}://${endpoint ?? '-'}` : ''
+
+ return {
+ apiUrl: apiHost ?? null,
+ anonKey: anonKey?.api_key ?? null,
+ publishableKey: publishableKey?.api_key ?? null,
+ }
+ }, [
+ settings?.app_config?.protocol,
+ settings?.app_config?.endpoint,
+ canReadAPIKeys,
+ anonKey?.api_key,
+ publishableKey?.api_key,
+ ])
+
return (
<Sheet open={showConnect} onOpenChange={handleOpenChange}>
<SheetContent size="lg" className="flex flex-col gap-0 p-0 space-y-0" tabIndex={undefined}>
<SheetHeader className={cn('text-left border-b shrink-0 py-6 px-8')}>
- <div className="flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between">
- <div>
- <SheetTitle>Connect to your project</SheetTitle>
- <SheetDescription>Choose how you want to use Supabase</SheetDescription>
- </div>
- </div>
+ <SheetTitle>Connect to your project</SheetTitle>
+ <SheetDescription>Choose how you want to use Supabase</SheetDescription>
</SheetHeader>
<div className="flex flex-1 flex-col overflow-y-auto">
- {/* Configuration Section */}
- <div className="space-y-6 border-b p-8 shrink-0"></div>
+ <div className="border-b p-8">
+ <ConnectConfigSection
+ activeFields={activeFields}
+ state={state}
+ onFieldChange={updateField}
+ getFieldOptions={getFieldOptions}
+ />
+ </div>
+
+ <ConnectStepsSection steps={resolvedSteps} state={state} projectKeys={projectKeys} />
</div>
</SheetContent>
</Sheet>
diff --git a/apps/studio/components/interfaces/ConnectSheet/ConnectSheetStep.tsx b/apps/studio/components/interfaces/ConnectSheet/ConnectSheetStep.tsx
new file mode 100644
index 00000000000..77f969c6cc5
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/ConnectSheetStep.tsx
@@ -0,0 +1,53 @@
+import { PropsWithChildren } from 'react'
+import { cn } from 'ui'
+
+interface ConnectSheetStepProps {
+ number: number
+ title: string
+ description: string
+ className?: string
+}
+
+export const ConnectSheetStep = ({
+ number,
+ title,
+ description,
+ className,
+ children,
+}: PropsWithChildren<ConnectSheetStepProps>) => {
+ return (
+ <div
+ className={cn('group', className)}
+ data-connect-step
+ data-step-title={title}
+ data-step-description={description}
+ >
+ <div className="flex items-start gap-6 self-stretch">
+ <div className="relative self-stretch shrink-0 w-6">
+ <div className="absolute inset-0 flex items-start justify-center">
+ <div
+ aria-hidden="true"
+ className={cn(
+ 'absolute left-[calc(50%-1px)] w-px bg-border opacity-60 h-full',
+ 'group-last:bg-transparent'
+ )}
+ />
+ <div className="relative z-10 flex font-mono text-xs items-center justify-center min-w-6 w-6 h-6 border border-default rounded-md bg-surface-100 text-foreground-light">
+ {number}
+ </div>
+ </div>
+ </div>
+
+ <div className="grid grid-cols-1 2xl:grid-cols-5 gap-x-6 gap-y-4 pb-12 w-full">
+ <div className="flex flex-col 2xl:col-span-2">
+ <p className="text-sm font-medium text-foreground">{title}</p>
+ <p className="text-sm text-foreground-light">{description}</p>
+ </div>
+ <div className="2xl:col-span-3 [&_pre.code-block]:!bg-surface-75" data-step-content>
+ {children}
+ </div>
+ </div>
+ </div>
+ </div>
+ )
+}
diff --git a/apps/studio/components/interfaces/ConnectSheet/ConnectStepsSection.tsx b/apps/studio/components/interfaces/ConnectSheet/ConnectStepsSection.tsx
new file mode 100644
index 00000000000..55288932b69
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/ConnectStepsSection.tsx
@@ -0,0 +1,181 @@
+import { useParams } from 'common'
+import { getAddons } from 'components/interfaces/Billing/Subscription/Subscription.utils'
+import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query'
+import { usePgbouncerConfigQuery } from 'data/database/pgbouncer-config-query'
+import { useSupavisorConfigurationQuery } from 'data/database/supavisor-configuration-query'
+import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
+import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
+import { pluckObjectFields } from 'lib/helpers'
+import dynamic from 'next/dynamic'
+import { useMemo, useRef } from 'react'
+import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
+
+import type {
+ ConnectionStringPooler,
+ ConnectState,
+ ProjectKeys,
+ ResolvedStep,
+ StepContentProps,
+} from './Connect.types'
+import { ConnectSheetStep } from './ConnectSheetStep'
+import { CopyPromptAdmonition } from './CopyPromptAdmonition'
+import { getConnectionStringPooler } from './DatabaseSettings.utils'
+
+interface ConnectStepsSectionProps {
+ steps: ResolvedStep[]
+ state: ConnectState
+ projectKeys: ProjectKeys
+}
+
+/**
+ * Resolves a content path template by replacing {{key}} placeholders with state values.
+ * Empty segments are filtered out to handle optional state values like frameworkVariant.
+ *
+ * Examples:
+ * - '{{framework}}/{{frameworkVariant}}/{{library}}' with state {framework: 'nextjs', frameworkVariant: 'app', library: 'supabasejs'}
+ * → 'nextjs/app/supabasejs'
+ * - '{{orm}}' with state {orm: 'prisma'}
+ * → 'prisma'
+ * - 'steps/install' (no templates)
+ * → 'steps/install'
+ */
+function resolveContentPath(template: string, state: ConnectState): string {
+ return template
+ .replace(/\{\{(\w+)\}\}/g, (_, key) => String(state[key] ?? ''))
+ .split('/')
+ .filter(Boolean)
+ .join('/')
+}
+
+/**
+ * Hook to fetch and prepare connection strings for step content.
+ */
+function useConnectionStringPooler(): ConnectionStringPooler {
+ const { ref: projectRef } = useParams()
+ const { data: selectedOrg } = useSelectedOrganizationQuery()
+ const allowPgBouncerSelection = useMemo(() => selectedOrg?.plan.id !== 'free', [selectedOrg])
+
+ const { data: settings } = useProjectSettingsV2Query({ projectRef })
+ const { data: pgbouncerConfig } = usePgbouncerConfigQuery({ projectRef })
+ const { data: supavisorConfig } = useSupavisorConfigurationQuery({ projectRef })
+ const { data: addons } = useProjectAddonsQuery({ projectRef })
+ const { ipv4: ipv4Addon } = getAddons(addons?.selected_addons ?? [])
+
+ const DB_FIELDS = ['db_host', 'db_name', 'db_port', 'db_user', 'inserted_at']
+ const emptyState = { db_user: '', db_host: '', db_port: '', db_name: '' }
+ const connectionInfo = pluckObjectFields(settings || emptyState, DB_FIELDS)
+ const poolingConfigurationShared = supavisorConfig?.find((x) => x.database_type === 'PRIMARY')
+ const poolingConfigurationDedicated = allowPgBouncerSelection ? pgbouncerConfig : undefined
+
+ const ConnectionStringPoolerShared = getConnectionStringPooler({
+ connectionInfo,
+ poolingInfo: {
+ connectionString: poolingConfigurationShared?.connection_string ?? '',
+ db_host: poolingConfigurationShared?.db_host ?? '',
+ db_name: poolingConfigurationShared?.db_name ?? '',
+ db_port: poolingConfigurationShared?.db_port ?? 0,
+ db_user: poolingConfigurationShared?.db_user ?? '',
+ },
+ metadata: { projectRef },
+ })
+
+ const ConnectionStringPoolerDedicated =
+ poolingConfigurationDedicated !== undefined
+ ? getConnectionStringPooler({
+ connectionInfo,
+ poolingInfo: {
+ connectionString: poolingConfigurationDedicated.connection_string,
+ db_host: poolingConfigurationDedicated.db_host,
+ db_name: poolingConfigurationDedicated.db_name,
+ db_port: poolingConfigurationDedicated.db_port,
+ db_user: poolingConfigurationDedicated.db_user,
+ },
+ metadata: { projectRef },
+ })
+ : undefined
+
+ return useMemo(
+ () => ({
+ transactionShared: ConnectionStringPoolerShared.pooler.uri,
+ sessionShared: ConnectionStringPoolerShared.pooler.uri.replace('6543', '5432'),
+ transactionDedicated: ConnectionStringPoolerDedicated?.pooler.uri,
+ sessionDedicated: ConnectionStringPoolerDedicated?.pooler.uri.replace('6543', '5432'),
+ ipv4SupportedForDedicatedPooler: !!ipv4Addon,
+ direct: ConnectionStringPoolerShared.direct.uri,
+ }),
+ [ConnectionStringPoolerShared, ConnectionStringPoolerDedicated, ipv4Addon]
+ )
+}
+
+/**
+ * Dynamically loads and renders a content component from the content directory.
+ * All step content uses this unified loader - no built-in component registry needed.
+ */
+function StepContent({
+ contentId,
+ state,
+ projectKeys,
+ connectionStringPooler,
+}: {
+ contentId: string
+ state: ConnectState
+ projectKeys: ProjectKeys
+ connectionStringPooler: ConnectionStringPooler
+}) {
+ // Resolve any template placeholders in the content path
+ const filePath = useMemo(() => resolveContentPath(contentId, state), [contentId, state])
+
+ // Dynamically import the content component
+ const ContentComponent = useMemo(() => {
+ return dynamic<StepContentProps>(() => import(`./content/${filePath}/content`), {
+ loading: () => (
+ <div className="p-4 min-h-[200px]">
+ <GenericSkeletonLoader />
+ </div>
+ ),
+ })
+ }, [filePath])
+
+ return (
+ <ContentComponent
+ state={state}
+ projectKeys={projectKeys}
+ connectionStringPooler={connectionStringPooler}
+ />
+ )
+}
+
+export function ConnectStepsSection({ steps, state, projectKeys }: ConnectStepsSectionProps) {
+ const stepsContainerRef = useRef<HTMLDivElement | null>(null)
+ const connectionStringPooler = useConnectionStringPooler()
+
+ if (steps.length === 0) return null
+
+ return (
+ <div className="bg-muted/50 flex-1">
+ <div className="p-8 flex flex-col gap-y-6">
+ <h3>Connect your app</h3>
+
+ <CopyPromptAdmonition stepsContainerRef={stepsContainerRef} />
+
+ <div className="mt-6" ref={stepsContainerRef}>
+ {steps.map((step, index) => (
+ <ConnectSheetStep
+ key={step.id}
+ number={index + 1}
+ title={step.title}
+ description={step.description}
+ >
+ <StepContent
+ contentId={step.content}
+ state={state}
+ projectKeys={projectKeys}
+ connectionStringPooler={connectionStringPooler}
+ />
+ </ConnectSheetStep>
+ ))}
+ </div>
+ </div>
+ </div>
+ )
+}
diff --git a/apps/studio/components/interfaces/ConnectSheet/ConnectionIcon.tsx b/apps/studio/components/interfaces/ConnectSheet/ConnectionIcon.tsx
new file mode 100644
index 00000000000..b2de0e20795
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/ConnectionIcon.tsx
@@ -0,0 +1,48 @@
+import { useTheme } from 'next-themes'
+import Image from 'next/image'
+
+import { BASE_PATH } from 'lib/constants'
+import { cn } from 'ui'
+
+interface ConnectionIconProps {
+ icon: string
+ iconFolder?: string
+ supportsDarkMode?: boolean
+ size?: number
+ className?: string
+}
+
+export const ConnectionIcon = ({
+ icon,
+ iconFolder,
+ supportsDarkMode,
+ size = 14,
+ className,
+}: ConnectionIconProps) => {
+ const { resolvedTheme } = useTheme()
+
+ const imageFolder =
+ iconFolder || (['ionic-angular'].includes(icon) ? 'icons/frameworks' : 'libraries')
+
+ const imageExtension = imageFolder === 'icons/frameworks' ? '' : '-icon'
+
+ const shouldUseDarkMode =
+ supportsDarkMode ||
+ ['expo', 'nextjs', 'prisma', 'drizzle', 'astro', 'remix', 'refine'].includes(icon.toLowerCase())
+
+ const iconImgSrc = icon.startsWith('http')
+ ? icon
+ : `${BASE_PATH}/img/${imageFolder}/${icon.toLowerCase()}${
+ shouldUseDarkMode && resolvedTheme?.includes('dark') ? '-dark' : ''
+ }${imageExtension}.svg`
+
+ return (
+ <Image
+ className={cn('transition-all group-hover:scale-110', className)}
+ src={iconImgSrc}
+ alt={`${icon} logo`}
+ width={size}
+ height={size}
+ />
+ )
+}
diff --git a/apps/studio/components/interfaces/ConnectSheet/ConnectionParameters.tsx b/apps/studio/components/interfaces/ConnectSheet/ConnectionParameters.tsx
new file mode 100644
index 00000000000..4fe75798555
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/ConnectionParameters.tsx
@@ -0,0 +1,52 @@
+import { Check, Copy } from 'lucide-react'
+import { useState } from 'react'
+import { cn, copyToClipboard } from 'ui'
+
+interface Parameter {
+ key: string
+ value: string
+}
+
+interface ConnectionParametersProps {
+ parameters: Parameter[]
+}
+
+export const ConnectionParameters = ({ parameters }: ConnectionParametersProps) => {
+ const [copiedMap, setCopiedMap] = useState<Record<string, boolean>>({})
+
+ return (
+ <div className="bg-surface-75 rounded-lg border font-mono text-sm p-4">
+ {parameters.map((param) => (
+ <div key={param.key} className="py-0.5 group/param">
+ <div className="text-xs flex items-center">
+ <span className="text-foreground-lighter">{param.key}:</span>
+ <span className="ml-1 text-foreground">{param.value}</span>
+ <button
+ onClick={() => {
+ copyToClipboard(param.value, () => {
+ setCopiedMap((prev) => ({ ...prev, [param.key]: true }))
+ setTimeout(() => {
+ setCopiedMap((prev) => ({ ...prev, [param.key]: false }))
+ }, 1000)
+ })
+ }}
+ className={cn(
+ 'text-foreground-lighter',
+ 'ml-2 opacity-0 group-hover/param:opacity-100',
+ 'hover:text-foreground rounded-sm p-1',
+ copiedMap[param.key] && 'opacity-100',
+ 'transition-all'
+ )}
+ >
+ {copiedMap[param.key] ? (
+ <Check size={12} strokeWidth={1.5} />
+ ) : (
+ <Copy size={12} strokeWidth={1.5} />
+ )}
+ </button>
+ </div>
+ </div>
+ ))}
+ </div>
+ )
+}
diff --git a/apps/studio/components/interfaces/ConnectSheet/ConnectionString.utils.ts b/apps/studio/components/interfaces/ConnectSheet/ConnectionString.utils.ts
new file mode 100644
index 00000000000..a681ca002c4
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/ConnectionString.utils.ts
@@ -0,0 +1,88 @@
+import type { ConnectionStringPooler } from './Connect.types'
+import type { ConnectionStringMethod } from './Connect.constants'
+
+export const DEFAULT_PORT = '5432'
+export const PASSWORD_PLACEHOLDER = '[YOUR-PASSWORD]'
+
+export type ConnectionParams = {
+ host: string
+ port: string
+ user: string
+ database: string
+}
+
+export const resolveConnectionString = ({
+ connectionMethod,
+ useSharedPooler,
+ connectionStringPooler,
+}: {
+ connectionMethod: ConnectionStringMethod
+ useSharedPooler: boolean
+ connectionStringPooler: ConnectionStringPooler
+}) => {
+ if (connectionMethod === 'direct') {
+ return connectionStringPooler.direct ?? ''
+ }
+
+ if (connectionMethod === 'session') {
+ return connectionStringPooler.sessionShared ?? ''
+ }
+
+ if (useSharedPooler || !connectionStringPooler.transactionDedicated) {
+ return connectionStringPooler.transactionShared ?? ''
+ }
+
+ return connectionStringPooler.transactionDedicated ?? ''
+}
+
+export const parseConnectionParams = (connectionString: string): ConnectionParams => {
+ if (!connectionString) {
+ return {
+ host: 'hidden',
+ port: DEFAULT_PORT,
+ user: 'hidden',
+ database: 'hidden',
+ }
+ }
+
+ try {
+ const parsed = new URL(connectionString)
+ return {
+ host: parsed.hostname || 'hidden',
+ port: parsed.port || DEFAULT_PORT,
+ user: parsed.username || 'hidden',
+ database: parsed.pathname?.replace(/^\//, '') || 'hidden',
+ }
+ } catch (error) {
+ return {
+ host: 'hidden',
+ port: DEFAULT_PORT,
+ user: 'hidden',
+ database: 'hidden',
+ }
+ }
+}
+
+export const buildSafeConnectionString = (
+ connectionString: string,
+ params: ConnectionParams
+): string => {
+ if (!connectionString) return ''
+
+ const search = (() => {
+ try {
+ return new URL(connectionString).search
+ } catch (error) {
+ return ''
+ }
+ })()
+
+ return `postgresql://${params.user}:${PASSWORD_PLACEHOLDER}@${params.host}:${params.port}/${params.database}${search}`
+}
+
+export const buildConnectionParameters = (params: ConnectionParams) => [
+ { key: 'host', value: params.host },
+ { key: 'port', value: params.port },
+ { key: 'database', value: params.database },
+ { key: 'user', value: params.user },
+]
diff --git a/apps/studio/components/interfaces/ConnectSheet/CopyPromptAdmonition.tsx b/apps/studio/components/interfaces/ConnectSheet/CopyPromptAdmonition.tsx
new file mode 100644
index 00000000000..1ced61a03bb
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/CopyPromptAdmonition.tsx
@@ -0,0 +1,157 @@
+import { BASE_PATH } from 'lib/constants'
+import { type RefObject } from 'react'
+import { Badge } from 'ui'
+import { Admonition } from 'ui-patterns/admonition'
+
+import CopyButton from '@/components/ui/CopyButton'
+
+interface CopyPromptAdmonitionProps {
+ stepsContainerRef: RefObject<HTMLDivElement | null>
+}
+
+export function CopyPromptAdmonition({ stepsContainerRef }: CopyPromptAdmonitionProps) {
+ const normalizeTextLines = (value: string) => {
+ return value
+ .split('\n')
+ .map((line) => line.trim())
+ .filter(Boolean)
+ .join('\n')
+ }
+
+ const getStepTextContent = (contentElement: HTMLElement) => {
+ const clone = contentElement.cloneNode(true) as HTMLElement
+ clone
+ .querySelectorAll('pre, button, svg, input, textarea, select, [aria-hidden="true"]')
+ .forEach((element) => {
+ element.remove()
+ })
+
+ const text = clone.textContent ?? ''
+ return normalizeTextLines(text)
+ }
+
+ const getStepCodeSnippets = (contentElement: HTMLElement) => {
+ const snippets: Array<{ label: string; snippet: string }> = []
+ const seen = new Set<string>()
+
+ const addSnippet = (label: string, snippet: string) => {
+ if (!snippet || seen.has(snippet)) return
+ seen.add(snippet)
+ snippets.push({ label, snippet })
+ }
+
+ const tabContents = Array.from(
+ contentElement.querySelectorAll('[data-connect-tab-content]')
+ ) as HTMLElement[]
+
+ tabContents.forEach((tabContent) => {
+ const label = tabContent.getAttribute('data-tab-label') || 'Code'
+ const tabSnippets = Array.from(tabContent.querySelectorAll('pre'))
+ .map((pre) => pre.textContent?.trim())
+ .filter((snippet): snippet is string => Boolean(snippet))
+
+ if (tabSnippets.length === 0) {
+ const inlineSnippets = Array.from(tabContent.querySelectorAll('code'))
+ .filter((code) => !code.closest('pre') && code.closest('.font-mono'))
+ .map((code) => code.textContent?.trim())
+ .filter((snippet): snippet is string => Boolean(snippet))
+ inlineSnippets.forEach((snippet, index) => {
+ const inlineLabel = inlineSnippets.length > 1 ? `${label} (part ${index + 1})` : label
+ addSnippet(inlineLabel, snippet)
+ })
+ return
+ }
+
+ tabSnippets.forEach((snippet, index) => {
+ const tabLabel = tabSnippets.length > 1 ? `${label} (part ${index + 1})` : label
+ addSnippet(tabLabel, snippet)
+ })
+ })
+
+ contentElement.querySelectorAll('pre').forEach((pre) => {
+ if (pre.closest('[data-connect-tab-content]')) return
+ const snippet = pre.textContent?.trim()
+ if (snippet) addSnippet('Code', snippet)
+ })
+
+ contentElement.querySelectorAll('code').forEach((code) => {
+ if (code.closest('pre')) return
+ if (code.closest('[data-connect-tab-content]')) return
+ if (!code.closest('.font-mono')) return
+ const snippet = code.textContent?.trim()
+ if (snippet) addSnippet('Code', snippet)
+ })
+
+ return snippets
+ }
+
+ const handleCopyPrompt = () => {
+ const stepElements = stepsContainerRef.current?.querySelectorAll('[data-connect-step]')
+ if (!stepElements?.length) return ''
+
+ const promptContent = Array.from(stepElements)
+ .map((stepElement, index) => {
+ const title = stepElement.getAttribute('data-step-title') ?? `Step ${index + 1}`
+ const description = stepElement.getAttribute('data-step-description') ?? ''
+ const contentElement = stepElement.querySelector(
+ '[data-step-content]'
+ ) as HTMLElement | null
+
+ const details = contentElement ? getStepTextContent(contentElement) : ''
+ const codeSnippets = contentElement ? getStepCodeSnippets(contentElement) : []
+
+ const sections = [
+ `${index + 1}. ${title}`,
+ description,
+ details ? `Details:\n${details}` : null,
+ codeSnippets.length
+ ? `Code:\n${codeSnippets
+ .map(({ label, snippet }) => `File: ${label}\n\`\`\`\n${snippet}\n\`\`\``)
+ .join('\n\n')}`
+ : null,
+ ].filter(Boolean)
+
+ return sections.join('\n')
+ })
+ .join('\n\n')
+
+ return promptContent
+ }
+
+ return (
+ <Admonition
+ type="tip"
+ showIcon={false}
+ layout="horizontal"
+ actions={<CopyButton type="default" copyLabel="Copy prompt" asyncText={handleCopyPrompt} />}
+ >
+ <div className="absolute -inset-16 z-0 opacity-50">
+ <img
+ src={`${BASE_PATH}/img/reports/bg-grafana-dark.svg`}
+ alt="Supabase Grafana"
+ className="w-full h-full object-cover object-right hidden dark:block"
+ />
+ <img
+ src={`${BASE_PATH}/img/reports/bg-grafana-light.svg`}
+ alt="Supabase Grafana"
+ className="w-full h-full object-cover object-right dark:hidden"
+ />
+ <div className="absolute inset-0 bg-gradient-to-r from-background-alternative to-transparent" />
+ </div>
+
+ <div className="relative flex flex-col md:flex-row md:items-center gap-y-2 md:gap-x-8 justify-between">
+ <div className="flex flex-col gap-y-0.5">
+ <div className="flex flex-col gap-y-2 items-start">
+ <Badge variant="success" className="-ml-0.5">
+ Skip the steps
+ </Badge>
+ <p className="heading-default">Prompt your agent</p>
+ </div>
+ <p className="text-sm text-foreground-lighter text-balance max-w-72">
+ Copy a prompt with everything your agent needs to connect your app for you.
+ </p>
+ </div>
+ </div>
+ </Admonition>
+ )
+}
diff --git a/apps/studio/components/interfaces/ConnectSheet/DatabaseSettings.utils.ts b/apps/studio/components/interfaces/ConnectSheet/DatabaseSettings.utils.ts
new file mode 100644
index 00000000000..402be854323
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/DatabaseSettings.utils.ts
@@ -0,0 +1,135 @@
+type ConnectionStringPooler = {
+ psql: string
+ uri: string
+ golang: string
+ jdbc: string
+ dotnet: string
+ nodejs: string
+ php: string
+ python: string
+ sqlalchemy: string
+}
+
+export const getConnectionStringPooler = ({
+ connectionInfo,
+ poolingInfo,
+ metadata,
+}: {
+ connectionInfo: {
+ db_user: string
+ db_port: number
+ db_host: string
+ db_name: string
+ }
+ poolingInfo?: {
+ connectionString: string
+ db_user: string
+ db_port: number
+ db_host: string
+ db_name: string
+ }
+ metadata: {
+ projectRef?: string
+ pgVersion?: string
+ }
+}): {
+ direct: ConnectionStringPooler
+ pooler: ConnectionStringPooler
+} => {
+ const isMd5 = poolingInfo?.connectionString?.includes('options=reference')
+ const { projectRef } = metadata
+ const password = '[YOUR-PASSWORD]'
+
+ // Direct connection variables
+ const directUser = connectionInfo.db_user
+ const directPort = connectionInfo.db_port
+ const directHost = connectionInfo.db_host
+ const directName = connectionInfo.db_name
+
+ // Pooler connection variables
+ const poolerUser = poolingInfo?.db_user
+ const poolerPort = poolingInfo?.db_port
+ const poolerHost = poolingInfo?.db_host
+ const poolerName = poolingInfo?.db_name
+
+ // Direct connection strings
+ const directPsqlString = isMd5
+ ? `psql "postgresql://${directUser}:${password}@${directHost}:${directPort}/${directName}"`
+ : `psql -h ${directHost} -p ${directPort} -d ${directName} -U ${directUser}`
+
+ const directUriString = `postgresql://${directUser}:${password}@${directHost}:${directPort}/${directName}`
+
+ const directGolangString = `DATABASE_URL=${directUriString}`
+
+ const directJdbcString = `jdbc:postgresql://${directHost}:${directPort}/${directName}?user=${directUser}&password=${password}`
+
+ // User Id=${directUser};Password=${password};Server=${directHost};Port=${directPort};Database=${directName}`
+ const directDotNetString = `{
+ "ConnectionStrings": {
+ "DefaultConnection": "Host=${directHost};Database=${directName};Username=${directUser};Password=${password};SSL Mode=Require;Trust Server Certificate=true"
+ }
+}`
+
+ // `User Id=${poolerUser};Password=${password};Server=${poolerHost};Port=${poolerPort};Database=${poolerName}${isMd5 ? `;Options='reference=${projectRef}'` : ''}`
+ const poolerDotNetString = `{
+ "ConnectionStrings": {
+ "DefaultConnection": "User Id=${poolerUser};Password=${password};Server=${poolerHost};Port=${poolerPort};Database=${poolerName}${isMd5 ? `;Options='reference=${projectRef}'` : ''}"
+ }
+}`
+
+ const directNodejsString = `DATABASE_URL=${directUriString}`
+
+ // Pooler connection strings
+ const poolerPsqlString = isMd5
+ ? `psql "postgresql://${poolerUser}:${password}@${poolerHost}:${poolerPort}/${poolerName}?options=reference%3D${projectRef}"`
+ : `psql -h ${poolerHost} -p ${poolerPort} -d ${poolerName} -U ${poolerUser}`
+
+ const poolerUriString = poolingInfo?.connectionString ?? ''
+
+ const nodejsPoolerUriString = `DATABASE_URL=${poolingInfo?.connectionString ?? ''}`
+
+ const poolerGolangString = `user=${poolerUser}
+password=${password}
+host=${poolerHost}
+port=${poolerPort}
+dbname=${poolerName}${isMd5 ? `options=reference=${projectRef}` : ''}`
+
+ const poolerJdbcString = `jdbc:postgresql://${poolerHost}:${poolerPort}/${poolerName}?user=${poolerUser}${isMd5 ? `&options=reference%3D${projectRef}` : ''}&password=${password}`
+
+ const sqlalchemyString = `user=${directUser}
+password=${password}
+host=${directHost}
+port=${directPort}
+dbname=${directName}`
+
+ const poolerSqlalchemyString = `user=${poolerUser}
+password=${password}
+host=${poolerHost}
+port=${poolerPort}
+dbname=${poolerName}`
+
+ return {
+ direct: {
+ psql: directPsqlString,
+ uri: directUriString,
+ golang: directGolangString,
+ jdbc: directJdbcString,
+ dotnet: directDotNetString,
+ nodejs: directNodejsString,
+ php: directGolangString,
+ python: directGolangString,
+ sqlalchemy: sqlalchemyString,
+ },
+ pooler: {
+ psql: poolerPsqlString,
+ uri: poolerUriString,
+ golang: poolerGolangString,
+ jdbc: poolerJdbcString,
+ dotnet: poolerDotNetString,
+ nodejs: nodejsPoolerUriString,
+ php: poolerGolangString,
+ python: poolerGolangString,
+ sqlalchemy: poolerSqlalchemyString,
+ },
+ }
+}
diff --git a/apps/studio/components/interfaces/ConnectSheet/DirectConnectionExamples.tsx b/apps/studio/components/interfaces/ConnectSheet/DirectConnectionExamples.tsx
new file mode 100644
index 00000000000..80084d1337d
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/DirectConnectionExamples.tsx
@@ -0,0 +1,153 @@
+export type Example = {
+ installCommands?: string[]
+ postInstallCommands?: string[]
+ files?: {
+ name: string
+ content: string
+ }[]
+}
+
+const examples = {
+ nodejs: {
+ installCommands: ['npm install postgres'],
+ files: [
+ {
+ name: 'db.js',
+ content: `import postgres from 'postgres'
+
+const connectionString = process.env.DATABASE_URL
+const sql = postgres(connectionString)
+
+export default sql`,
+ },
+ ],
+ },
+ golang: {
+ installCommands: ['go get github.com/jackc/pgx/v5'],
+ files: [
+ {
+ name: 'main.go',
+ content: `package main
+
+import (
+ "context"
+ "log"
+ "os"
+ "github.com/jackc/pgx/v5"
+)
+
+func main() {
+ conn, err := pgx.Connect(context.Background(), os.Getenv("DATABASE_URL"))
+ if err != nil {
+ log.Fatalf("Failed to connect to the database: %v", err)
+ }
+ defer conn.Close(context.Background())
+
+ // Example query to test connection
+ var version string
+ if err := conn.QueryRow(context.Background(), "SELECT version()").Scan(&version); err != nil {
+ log.Fatalf("Query failed: %v", err)
+ }
+
+ log.Println("Connected to:", version)
+}`,
+ },
+ ],
+ },
+ dotnet: {
+ installCommands: [
+ 'dotnet add package Microsoft.Extensions.Configuration.Json --version YOUR_DOTNET_VERSION',
+ ],
+ postInstallCommands: [
+ 'dotnet add package Microsoft.Extensions.Configuration.Json --version YOUR_DOTNET_VERSION',
+ ],
+ },
+ python: {
+ installCommands: ['pip install python-dotenv psycopg2'],
+ files: [
+ {
+ name: 'main.py',
+ content: `import psycopg2
+from dotenv import load_dotenv
+import os
+
+# Load environment variables from .env
+load_dotenv()
+
+# Fetch variables
+USER = os.getenv("user")
+PASSWORD = os.getenv("password")
+HOST = os.getenv("host")
+PORT = os.getenv("port")
+DBNAME = os.getenv("dbname")
+
+# Connect to the database
+try:
+ connection = psycopg2.connect(
+ user=USER,
+ password=PASSWORD,
+ host=HOST,
+ port=PORT,
+ dbname=DBNAME
+ )
+ print("Connection successful!")
+
+ # Create a cursor to execute SQL queries
+ cursor = connection.cursor()
+
+ # Example query
+ cursor.execute("SELECT NOW();")
+ result = cursor.fetchone()
+ print("Current Time:", result)
+
+ # Close the cursor and connection
+ cursor.close()
+ connection.close()
+ print("Connection closed.")
+
+except Exception as e:
+ print(f"Failed to connect: {e}")`,
+ },
+ ],
+ },
+ sqlalchemy: {
+ installCommands: ['pip install python-dotenv sqlalchemy psycopg2'],
+ files: [
+ {
+ name: 'main.py',
+ content: `from sqlalchemy import create_engine
+# from sqlalchemy.pool import NullPool
+from dotenv import load_dotenv
+import os
+
+# Load environment variables from .env
+load_dotenv()
+
+# Fetch variables
+USER = os.getenv("user")
+PASSWORD = os.getenv("password")
+HOST = os.getenv("host")
+PORT = os.getenv("port")
+DBNAME = os.getenv("dbname")
+
+# Construct the SQLAlchemy connection string
+DATABASE_URL = f"postgresql+psycopg2://{USER}:{PASSWORD}@{HOST}:{PORT}/{DBNAME}?sslmode=require"
+
+# Create the SQLAlchemy engine
+engine = create_engine(DATABASE_URL)
+# If using Transaction Pooler or Session Pooler, we want to ensure we disable SQLAlchemy client side pooling -
+# https://docs.sqlalchemy.org/en/20/core/pooling.html#switching-pool-implementations
+# engine = create_engine(DATABASE_URL, poolclass=NullPool)
+
+# Test the connection
+try:
+ with engine.connect() as connection:
+ print("Connection successful!")
+except Exception as e:
+ print(f"Failed to connect: {e}")`,
+ },
+ ],
+ },
+}
+
+export default examples
diff --git a/apps/studio/components/interfaces/ConnectSheet/connect.resolver.test.ts b/apps/studio/components/interfaces/ConnectSheet/connect.resolver.test.ts
new file mode 100644
index 00000000000..30f264907c4
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/connect.resolver.test.ts
@@ -0,0 +1,614 @@
+import { describe, expect, test } from 'vitest'
+
+import type { ConditionalValue, ConnectSchema, StepTree } from './Connect.types'
+import {
+ getActiveFields,
+ getDefaultState,
+ resolveConditional,
+ resolveState,
+ resolveSteps,
+} from './connect.resolver'
+
+// ============================================================================
+// resolveConditional Tests
+// ============================================================================
+
+describe('connect.resolver:resolveConditional', () => {
+ test('should return primitive values directly', () => {
+ expect(resolveConditional('hello', { mode: 'framework' })).toBe('hello')
+ expect(resolveConditional(42, { mode: 'framework' })).toBe(42)
+ expect(resolveConditional(null, { mode: 'framework' })).toBe(null)
+ expect(resolveConditional(true, { mode: 'framework' })).toBe(true)
+ })
+
+ test('should return arrays directly', () => {
+ const arr = ['a', 'b', 'c']
+ expect(resolveConditional(arr, { mode: 'framework' })).toBe(arr)
+ })
+
+ test('should resolve single-level conditional based on mode', () => {
+ const conditional: ConditionalValue<string> = {
+ framework: 'Framework Content',
+ direct: 'Direct Content',
+ DEFAULT: 'Default Content',
+ }
+
+ expect(resolveConditional(conditional, { mode: 'framework' })).toBe('Framework Content')
+ expect(resolveConditional(conditional, { mode: 'direct' })).toBe('Direct Content')
+ expect(resolveConditional(conditional, { mode: 'orm' })).toBe('Default Content')
+ })
+
+ test('should resolve nested conditionals (mode -> framework)', () => {
+ const conditional: ConditionalValue<string> = {
+ framework: {
+ nextjs: 'Next.js Content',
+ react: 'React Content',
+ DEFAULT: 'Generic Framework',
+ },
+ direct: 'Direct Content',
+ }
+
+ expect(resolveConditional(conditional, { mode: 'framework', framework: 'nextjs' })).toBe(
+ 'Next.js Content'
+ )
+ expect(resolveConditional(conditional, { mode: 'framework', framework: 'react' })).toBe(
+ 'React Content'
+ )
+ expect(resolveConditional(conditional, { mode: 'framework', framework: 'vue' })).toBe(
+ 'Generic Framework'
+ )
+ expect(resolveConditional(conditional, { mode: 'direct' })).toBe('Direct Content')
+ })
+
+ test('should resolve deeply nested conditionals (mode -> framework -> variant)', () => {
+ const conditional: ConditionalValue<string> = {
+ framework: {
+ nextjs: {
+ app: 'App Router Content',
+ pages: 'Pages Router Content',
+ DEFAULT: 'Generic Next.js',
+ },
+ DEFAULT: 'Generic Framework',
+ },
+ }
+
+ expect(
+ resolveConditional(conditional, {
+ mode: 'framework',
+ framework: 'nextjs',
+ frameworkVariant: 'app',
+ })
+ ).toBe('App Router Content')
+ expect(
+ resolveConditional(conditional, {
+ mode: 'framework',
+ framework: 'nextjs',
+ frameworkVariant: 'pages',
+ })
+ ).toBe('Pages Router Content')
+ expect(
+ resolveConditional(conditional, {
+ mode: 'framework',
+ framework: 'nextjs',
+ frameworkVariant: 'unknown',
+ })
+ ).toBe('Generic Next.js')
+ })
+
+ test('should resolve MCP client-specific content', () => {
+ const conditional: ConditionalValue<string> = {
+ mcp: {
+ cursor: 'Cursor Config',
+ codex: 'Codex Config',
+ 'claude-code': 'Claude Code Config',
+ DEFAULT: 'Generic MCP',
+ },
+ }
+
+ expect(resolveConditional(conditional, { mode: 'mcp', mcpClient: 'cursor' })).toBe(
+ 'Cursor Config'
+ )
+ expect(resolveConditional(conditional, { mode: 'mcp', mcpClient: 'codex' })).toBe(
+ 'Codex Config'
+ )
+ expect(resolveConditional(conditional, { mode: 'mcp', mcpClient: 'claude-code' })).toBe(
+ 'Claude Code Config'
+ )
+ })
+
+ test('should return undefined when no match and no DEFAULT', () => {
+ const conditional: ConditionalValue<string> = {
+ framework: 'Framework',
+ direct: 'Direct',
+ }
+
+ expect(resolveConditional(conditional, { mode: 'orm' })).toBe(undefined)
+ })
+
+ test('should handle frameworkUi boolean state (as string "true"/"false")', () => {
+ const conditional: ConditionalValue<string> = {
+ framework: {
+ nextjs: {
+ true: 'Shadcn Steps',
+ DEFAULT: 'Regular Steps',
+ },
+ },
+ }
+
+ // When frameworkUi is true (boolean), it gets converted to string "true"
+ expect(
+ resolveConditional(conditional, { mode: 'framework', framework: 'nextjs', frameworkUi: true })
+ ).toBe('Shadcn Steps')
+ expect(
+ resolveConditional(conditional, {
+ mode: 'framework',
+ framework: 'nextjs',
+ frameworkUi: false,
+ })
+ ).toBe('Regular Steps')
+ })
+})
+
+// ============================================================================
+// resolveSteps Tests
+// ============================================================================
+
+describe('connect.resolver:resolveSteps', () => {
+ const createMockSchema = (steps: StepTree): ConnectSchema => ({
+ fields: {},
+ steps,
+ })
+
+ test('should resolve steps array for framework mode', () => {
+ const schema = createMockSchema({
+ mode: {
+ framework: [
+ { id: 'step1', title: 'Install', description: 'Install pkg', content: 'install-content' },
+ { id: 'step2', title: 'Configure', description: 'Configure', content: 'config-content' },
+ ],
+ direct: [
+ {
+ id: 'connection',
+ title: 'Connection',
+ description: 'Connect',
+ content: 'direct-content',
+ },
+ ],
+ },
+ })
+
+ const steps = resolveSteps(schema, { mode: 'framework' })
+ expect(steps).toHaveLength(2)
+ expect(steps[0].id).toBe('step1')
+ expect(steps[0].title).toBe('Install')
+ expect(steps[1].id).toBe('step2')
+ })
+
+ test('should resolve steps for direct mode', () => {
+ const schema = createMockSchema({
+ mode: {
+ framework: [{ id: 'step1', title: 'Install', description: 'Install', content: 'install' }],
+ direct: [
+ { id: 'connection', title: 'Connection', description: 'Connect', content: 'direct' },
+ ],
+ },
+ })
+
+ const steps = resolveSteps(schema, { mode: 'direct' })
+ expect(steps).toHaveLength(1)
+ expect(steps[0].id).toBe('connection')
+ })
+
+ test('should filter out steps with empty content', () => {
+ const schema = createMockSchema({
+ mode: {
+ framework: [
+ { id: 'step1', title: 'Valid', description: 'Valid step', content: 'valid-content' },
+ { id: 'step2', title: 'Empty', description: 'Empty step', content: '' },
+ { id: 'step3', title: 'Null', description: 'Null step', content: null },
+ ],
+ },
+ })
+
+ const steps = resolveSteps(schema, { mode: 'framework' })
+ expect(steps).toHaveLength(1)
+ expect(steps[0].id).toBe('step1')
+ })
+
+ test('should resolve conditional step content based on state', () => {
+ const schema = createMockSchema({
+ mode: {
+ framework: [
+ {
+ id: 'configure',
+ title: 'Configure',
+ description: 'Configure',
+ content: {
+ nextjs: 'nextjs-content',
+ react: 'react-content',
+ DEFAULT: 'generic-content',
+ },
+ },
+ ],
+ },
+ })
+
+ const nextjsSteps = resolveSteps(schema, { mode: 'framework', framework: 'nextjs' })
+ expect(nextjsSteps[0].content).toBe('nextjs-content')
+
+ const reactSteps = resolveSteps(schema, { mode: 'framework', framework: 'react' })
+ expect(reactSteps[0].content).toBe('react-content')
+
+ const vueSteps = resolveSteps(schema, { mode: 'framework', framework: 'vue' })
+ expect(vueSteps[0].content).toBe('generic-content')
+ })
+
+ test('should return empty array when no steps resolve', () => {
+ const schema = createMockSchema({
+ mode: {
+ framework: [{ id: 'step1', title: 'Step', description: 'Desc', content: '' }],
+ },
+ })
+
+ const steps = resolveSteps(schema, { mode: 'framework' })
+ expect(steps).toEqual([])
+ })
+
+ test('should return empty array when steps is not an array', () => {
+ const schema = createMockSchema({
+ mode: {
+ framework: {
+ framework: {},
+ },
+ },
+ } as any)
+
+ const steps = resolveSteps(schema, { mode: 'framework' })
+ expect(steps).toEqual([])
+ })
+
+ test('should append steps from multiple field conditions in order', () => {
+ const schema = createMockSchema({
+ mode: {
+ framework: {
+ framework: {
+ nextjs: [{ id: 'base', title: 'Base', description: 'Base step', content: 'base' }],
+ },
+ frameworkUi: {
+ true: [{ id: 'ui', title: 'UI', description: 'UI step', content: 'ui' }],
+ },
+ },
+ },
+ })
+
+ const steps = resolveSteps(schema, {
+ mode: 'framework',
+ framework: 'nextjs',
+ frameworkUi: true,
+ })
+ expect(steps.map((step) => step.id)).toEqual(['base', 'ui'])
+ })
+})
+
+// ============================================================================
+// getActiveFields Tests
+// ============================================================================
+
+describe('connect.resolver:getActiveFields', () => {
+ const createSchemaWithFields = (fields: ConnectSchema['fields']): ConnectSchema => ({
+ fields,
+ steps: [],
+ })
+
+ test('should return fields for the current mode', () => {
+ const schema = createSchemaWithFields({
+ mode: {
+ id: 'mode',
+ type: 'select',
+ label: 'Mode',
+ defaultValue: 'framework',
+ options: () => [
+ { value: 'framework', label: 'Framework' },
+ { value: 'direct', label: 'Direct' },
+ ],
+ },
+ framework: {
+ id: 'framework',
+ type: 'radio-grid',
+ label: 'Framework',
+ defaultValue: 'nextjs',
+ dependsOn: { mode: ['framework'] },
+ },
+ library: {
+ id: 'library',
+ type: 'select',
+ label: 'Library',
+ defaultValue: 'supabasejs',
+ dependsOn: { mode: ['framework'] },
+ },
+ connectionType: {
+ id: 'connectionType',
+ type: 'select',
+ label: 'Type',
+ defaultValue: 'uri',
+ dependsOn: { mode: ['direct'] },
+ },
+ })
+
+ const frameworkFields = getActiveFields(schema, { mode: 'framework' })
+ expect(frameworkFields.map((f) => f.id)).toEqual(['mode', 'framework', 'library'])
+
+ const directFields = getActiveFields(schema, { mode: 'direct' })
+ expect(directFields.map((f) => f.id)).toEqual(['mode', 'connectionType'])
+ })
+
+ test('should filter fields by dependsOn conditions', () => {
+ const schema = createSchemaWithFields({
+ mode: {
+ id: 'mode',
+ type: 'select',
+ label: 'Mode',
+ defaultValue: 'framework',
+ options: () => [{ value: 'framework', label: 'Framework' }],
+ },
+ framework: {
+ id: 'framework',
+ type: 'radio-grid',
+ label: 'Framework',
+ defaultValue: 'nextjs',
+ dependsOn: { mode: ['framework'] },
+ },
+ frameworkVariant: {
+ id: 'frameworkVariant',
+ type: 'select',
+ label: 'Variant',
+ dependsOn: { mode: ['framework'], framework: ['nextjs', 'react'] },
+ },
+ frameworkUi: {
+ id: 'frameworkUi',
+ type: 'switch',
+ label: 'Shadcn',
+ dependsOn: { mode: ['framework'], framework: ['nextjs', 'react'] },
+ },
+ })
+
+ // With nextjs - should show all fields
+ const nextjsFields = getActiveFields(schema, { mode: 'framework', framework: 'nextjs' })
+ expect(nextjsFields).toHaveLength(4)
+
+ // With vue - should hide frameworkVariant and frameworkUi
+ const vueFields = getActiveFields(schema, { mode: 'framework', framework: 'vue' })
+ expect(vueFields.map((field) => field.id)).toEqual(['mode', 'framework'])
+ })
+
+ test('should handle multiple dependsOn conditions', () => {
+ const schema = createSchemaWithFields({
+ mode: {
+ id: 'mode',
+ type: 'select',
+ label: 'Mode',
+ defaultValue: 'direct',
+ options: () => [{ value: 'direct', label: 'Direct' }],
+ },
+ connectionMethod: {
+ id: 'connectionMethod',
+ type: 'radio-list',
+ label: 'Method',
+ defaultValue: 'direct',
+ dependsOn: { mode: ['direct'] },
+ },
+ useSharedPooler: {
+ id: 'useSharedPooler',
+ type: 'switch',
+ label: 'Use Shared Pooler',
+ dependsOn: { mode: ['direct'], connectionMethod: ['transaction'] },
+ },
+ })
+
+ // Transaction mode - show shared pooler option
+ const transactionFields = getActiveFields(schema, {
+ mode: 'direct',
+ connectionMethod: 'transaction',
+ })
+ expect(transactionFields.map((field) => field.id)).toEqual([
+ 'mode',
+ 'connectionMethod',
+ 'useSharedPooler',
+ ])
+
+ // Direct mode - hide shared pooler option
+ const directFields = getActiveFields(schema, { mode: 'direct', connectionMethod: 'direct' })
+ expect(directFields.map((field) => field.id)).toEqual(['mode', 'connectionMethod'])
+ })
+
+ test('should return only mode field when dependsOn does not match', () => {
+ const schema = createSchemaWithFields({
+ mode: {
+ id: 'mode',
+ type: 'select',
+ label: 'Mode',
+ defaultValue: 'framework',
+ options: () => [{ value: 'framework', label: 'Framework' }],
+ },
+ framework: {
+ id: 'framework',
+ type: 'radio-grid',
+ label: 'Framework',
+ dependsOn: { mode: ['framework'] },
+ },
+ })
+
+ const fields = getActiveFields(schema, { mode: 'invalid' as any })
+ expect(fields.map((field) => field.id)).toEqual(['mode'])
+ })
+
+ test('should include resolvedOptions for each field', () => {
+ const schema = createSchemaWithFields({
+ framework: {
+ id: 'framework',
+ type: 'radio-grid',
+ label: 'Framework',
+ options: () => [{ value: 'nextjs', label: 'Next.js' }],
+ },
+ })
+
+ const fields = getActiveFields(schema, { mode: 'framework' })
+ expect(fields[0]).toHaveProperty('resolvedOptions')
+ expect(fields[0].resolvedOptions).toEqual([{ value: 'nextjs', label: 'Next.js' }])
+ })
+})
+
+// ============================================================================
+// getDefaultState Tests
+// ============================================================================
+
+describe('connect.resolver:getDefaultState', () => {
+ test('should include default values from fields', () => {
+ const schema: ConnectSchema = {
+ fields: {
+ mode: {
+ id: 'mode',
+ type: 'select',
+ label: 'Mode',
+ defaultValue: 'framework',
+ options: () => [{ value: 'framework', label: 'Framework' }],
+ },
+ framework: {
+ id: 'framework',
+ type: 'radio-grid',
+ label: 'Framework',
+ defaultValue: 'nextjs',
+ dependsOn: { mode: ['framework'] },
+ },
+ library: {
+ id: 'library',
+ type: 'select',
+ label: 'Library',
+ defaultValue: 'supabasejs',
+ dependsOn: { mode: ['framework'] },
+ },
+ mcpReadonly: {
+ id: 'mcpReadonly',
+ type: 'switch',
+ label: 'Readonly',
+ defaultValue: false,
+ },
+ },
+ steps: [],
+ }
+
+ const state = getDefaultState(schema)
+ expect(state.framework).toBe('nextjs')
+ expect(state.library).toBe('supabasejs')
+ expect(state.mcpReadonly).toBe(false)
+ })
+})
+
+// ============================================================================
+// resolveState Tests
+// ============================================================================
+
+describe('connect.resolver:resolveState', () => {
+ test('should apply defaults from options when valid', () => {
+ const schema: ConnectSchema = {
+ fields: {
+ mode: {
+ id: 'mode',
+ type: 'select',
+ label: 'Mode',
+ defaultValue: 'framework',
+ options: () => [{ value: 'framework', label: 'Framework' }],
+ },
+ framework: {
+ id: 'framework',
+ type: 'select',
+ label: 'Framework',
+ defaultValue: 'react',
+ options: () => [
+ { value: 'nextjs', label: 'Next.js' },
+ { value: 'react', label: 'React' },
+ ],
+ dependsOn: { mode: ['framework'] },
+ },
+ },
+ steps: [],
+ }
+
+ const state = resolveState(schema, {})
+ expect(state.mode).toBe('framework')
+ expect(state.framework).toBe('react')
+ })
+
+ test('should fall back to first option when default is invalid', () => {
+ const schema: ConnectSchema = {
+ fields: {
+ mode: {
+ id: 'mode',
+ type: 'select',
+ label: 'Mode',
+ defaultValue: 'framework',
+ options: () => [{ value: 'framework', label: 'Framework' }],
+ },
+ framework: {
+ id: 'framework',
+ type: 'select',
+ label: 'Framework',
+ defaultValue: 'angular',
+ options: () => [
+ { value: 'nextjs', label: 'Next.js' },
+ { value: 'react', label: 'React' },
+ ],
+ dependsOn: { mode: ['framework'] },
+ },
+ },
+ steps: [],
+ }
+
+ const state = resolveState(schema, {})
+ expect(state.framework).toBe('nextjs')
+ })
+
+ test('should refresh dependent values when options change', () => {
+ const schema: ConnectSchema = {
+ fields: {
+ mode: {
+ id: 'mode',
+ type: 'select',
+ label: 'Mode',
+ defaultValue: 'framework',
+ options: () => [{ value: 'framework', label: 'Framework' }],
+ },
+ framework: {
+ id: 'framework',
+ type: 'select',
+ label: 'Framework',
+ defaultValue: 'nextjs',
+ options: () => [
+ { value: 'nextjs', label: 'Next.js' },
+ { value: 'react', label: 'React' },
+ ],
+ dependsOn: { mode: ['framework'] },
+ },
+ variant: {
+ id: 'variant',
+ type: 'select',
+ label: 'Variant',
+ options: (state) =>
+ state.framework === 'react'
+ ? [{ value: 'vite', label: 'Vite' }]
+ : [{ value: 'app', label: 'App' }],
+ dependsOn: { mode: ['framework'], framework: ['nextjs', 'react'] },
+ },
+ },
+ steps: [],
+ }
+
+ const state = resolveState(schema, {
+ mode: 'framework',
+ framework: 'react',
+ variant: 'app',
+ })
+
+ expect(state.variant).toBe('vite')
+ })
+})
diff --git a/apps/studio/components/interfaces/ConnectSheet/connect.resolver.ts b/apps/studio/components/interfaces/ConnectSheet/connect.resolver.ts
new file mode 100644
index 00000000000..019224ffe14
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/connect.resolver.ts
@@ -0,0 +1,281 @@
+import type {
+ ConditionalValue,
+ ConnectSchema,
+ ConnectState,
+ FieldOption,
+ ResolvedField,
+ ResolvedStep,
+ StepDefinition,
+ StepFieldValueMap,
+ StepTree,
+} from './Connect.types'
+
+/**
+ * Check if a value is a conditional object (has nested state keys or DEFAULT)
+ */
+function isConditionalObject(value: unknown): value is Record<string, unknown> {
+ return typeof value === 'object' && value !== null && !Array.isArray(value)
+}
+
+/**
+ * Resolves a conditional value based on current state.
+ * Walks the tree using stateKeys in order, falling back to DEFAULT at each level.
+ *
+ * Example: Given state { mode: 'mcp', mcpClient: 'codex' }
+ * and stateKeys derived from schema field order
+ *
+ * 1. Look up 'mcp' (state.mode value) in tree -> found, continue
+ * 2. At mcp subtree { codex: [...], DEFAULT: [...] }, skip irrelevant keys
+ * until we find a key whose state value matches an entry in the object
+ * 3. Look up 'codex' (state.mcpClient value) in that subtree -> found, return value
+ * 4. If no state key matches, try DEFAULT at that level
+ */
+export function resolveConditional<T>(
+ value: ConditionalValue<T>,
+ state: ConnectState,
+ stateKeys: readonly string[] = Object.keys(state)
+): T | undefined {
+ // Base case: we've reached a leaf value (string, array, null, boolean, etc.)
+ if (!isConditionalObject(value)) {
+ return value as T
+ }
+
+ const conditionalObj = value as Record<string, ConditionalValue<T>>
+ const objectKeys = Object.keys(conditionalObj).filter((k) => k !== 'DEFAULT')
+
+ // Try each state key in order to find one that matches an entry in the object
+ for (let i = 0; i < stateKeys.length; i++) {
+ const currentKey = stateKeys[i]
+ const stateValue = String(state[currentKey] ?? '')
+
+ // If this state value matches a key in the conditional object, use it
+ if (stateValue && objectKeys.includes(stateValue)) {
+ const nextValue = conditionalObj[stateValue]
+ // Continue resolving with remaining keys (after this one)
+ return resolveConditional(nextValue, state, stateKeys.slice(i + 1))
+ }
+ }
+
+ // No state key matched - use DEFAULT if available
+ if (conditionalObj.DEFAULT !== undefined) {
+ return resolveConditional(conditionalObj.DEFAULT, state, stateKeys)
+ }
+
+ return undefined
+}
+
+/**
+ * Resolves the steps array based on current state.
+ * Returns only steps that have non-null content.
+ */
+export function resolveSteps(schema: ConnectSchema, state: ConnectState): ResolvedStep[] {
+ const steps = resolveStepTree(schema.steps, state)
+ if (steps.length === 0) return []
+ const stateKeys = Object.keys(schema.fields)
+ const resolutionKeys = stateKeys.length > 0 ? stateKeys : Object.keys(state)
+
+ return steps
+ .map((step) => {
+ const content = resolveConditional<string | null>(step.content, state, resolutionKeys)
+ return {
+ id: step.id,
+ title: step.title,
+ description: step.description,
+ content: content ?? '',
+ }
+ })
+ .filter((step) => step.content !== '' && step.content !== null)
+}
+
+/**
+ * Resolves a step tree by evaluating field-specific branches in insertion order.
+ * Each matching branch appends its steps to the final list.
+ */
+function resolveStepTree(tree: StepTree, state: ConnectState): StepDefinition[] {
+ if (Array.isArray(tree)) return tree
+ if (!isConditionalObject(tree)) return []
+
+ const resolved: StepDefinition[] = []
+
+ for (const [fieldId, valueMap] of Object.entries(tree)) {
+ if (fieldId === 'DEFAULT') continue
+ if (!isConditionalObject(valueMap)) continue
+
+ const branch = resolveStepBranch(valueMap as StepFieldValueMap, state[fieldId])
+ if (!branch) continue
+
+ resolved.push(...resolveStepTree(branch, state))
+ }
+
+ return resolved
+}
+
+function resolveStepBranch(
+ valueMap: StepFieldValueMap,
+ stateValue: ConnectState[keyof ConnectState] | undefined
+): StepTree | undefined {
+ const key = String(stateValue ?? '')
+ if (key && Object.prototype.hasOwnProperty.call(valueMap, key)) {
+ return valueMap[key]
+ }
+
+ if (valueMap.DEFAULT !== undefined) {
+ return valueMap.DEFAULT
+ }
+
+ return undefined
+}
+
+/**
+ * Gets the active fields for the current mode, filtering by dependsOn conditions.
+ */
+export function getActiveFields(schema: ConnectSchema, state: ConnectState): ResolvedField[] {
+ const stateKeys = Object.keys(schema.fields)
+
+ return stateKeys
+ .map((fieldId) => schema.fields[fieldId])
+ .filter((field): field is NonNullable<typeof field> => !!field)
+ .filter((field) => {
+ // Check dependsOn conditions
+ if (!field.dependsOn) return true
+ return Object.entries(field.dependsOn).every(([key, values]) => {
+ const stateValue = String(state[key] ?? '')
+ return values.includes(stateValue)
+ })
+ })
+ .map((field) => ({
+ ...field,
+ resolvedOptions: resolveFieldOptions(field, state, stateKeys),
+ }))
+}
+
+/**
+ * Resolves field options based on current state.
+ */
+function resolveFieldOptions(
+ field: { options?: unknown },
+ state: ConnectState,
+ stateKeys: readonly string[]
+): FieldOption[] {
+ if (!field.options) return []
+
+ // Static options array
+ if (Array.isArray(field.options)) {
+ return field.options
+ }
+
+ if (typeof field.options === 'function') {
+ return (field.options as (state: ConnectState) => FieldOption[])(state)
+ }
+
+ // Conditional options
+ if (typeof field.options === 'object') {
+ const resolved = resolveConditional<FieldOption[]>(
+ field.options as ConditionalValue<FieldOption[]>,
+ state,
+ stateKeys
+ )
+ return resolved ?? []
+ }
+
+ return []
+}
+
+/**
+ * Normalizes state values based on schema defaults, options, and dependencies.
+ */
+export function resolveState(
+ schema: ConnectSchema,
+ inputState: Partial<ConnectState>
+): ConnectState {
+ const next: ConnectState = { ...(inputState as ConnectState) }
+
+ const maxIterations = Math.max(1, Object.keys(schema.fields).length + 1)
+
+ for (let iteration = 0; iteration < maxIterations; iteration++) {
+ let changed = false
+ const activeFields = getActiveFields(schema, next)
+
+ for (const field of activeFields) {
+ const currentValue = next[field.id]
+ const optionValues = field.resolvedOptions.map((option) => option.value)
+ const hasOptions = optionValues.length > 0
+
+ if (field.type === 'switch') {
+ if (typeof currentValue !== 'boolean' && typeof field.defaultValue === 'boolean') {
+ next[field.id] = field.defaultValue
+ changed = true
+ }
+ continue
+ }
+
+ if (field.type === 'multi-select') {
+ if (Array.isArray(currentValue)) {
+ if (hasOptions) {
+ const filtered = currentValue.filter((value) => optionValues.includes(String(value)))
+ if (filtered.length !== currentValue.length) {
+ next[field.id] = filtered
+ changed = true
+ }
+ }
+ } else if (Array.isArray(field.defaultValue)) {
+ next[field.id] = field.defaultValue
+ changed = true
+ }
+ continue
+ }
+
+ if (typeof currentValue !== 'string') {
+ let nextValue: string | undefined
+
+ if (
+ typeof field.defaultValue === 'string' &&
+ (!hasOptions || optionValues.includes(field.defaultValue))
+ ) {
+ nextValue = field.defaultValue
+ } else if (hasOptions) {
+ nextValue = optionValues[0]
+ }
+
+ if (nextValue !== undefined) {
+ next[field.id] = nextValue
+ changed = true
+ }
+ continue
+ }
+
+ if (hasOptions && !optionValues.includes(currentValue)) {
+ let nextValue: string | undefined
+
+ if (typeof field.defaultValue === 'string' && optionValues.includes(field.defaultValue)) {
+ nextValue = field.defaultValue
+ } else {
+ nextValue = optionValues[0]
+ }
+
+ if (nextValue !== currentValue) {
+ next[field.id] = nextValue
+ changed = true
+ }
+ }
+ }
+
+ if (!changed) break
+ }
+
+ const activeIds = new Set(getActiveFields(schema, next).map((field) => field.id))
+ Object.keys(schema.fields).forEach((fieldId) => {
+ if (!activeIds.has(fieldId)) {
+ delete next[fieldId]
+ }
+ })
+
+ return next
+}
+
+/**
+ * Gets default state for the schema, using first mode and default field values.
+ */
+export function getDefaultState(schema: ConnectSchema): ConnectState {
+ return resolveState(schema, {})
+}
diff --git a/apps/studio/components/interfaces/ConnectSheet/connect.schema.test.ts b/apps/studio/components/interfaces/ConnectSheet/connect.schema.test.ts
new file mode 100644
index 00000000000..750d08f6976
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/connect.schema.test.ts
@@ -0,0 +1,266 @@
+import { describe, expect, test } from 'vitest'
+
+import { INSTALL_COMMANDS } from './Connect.constants'
+import type { ConnectState } from './Connect.types'
+import { resolveSteps } from './connect.resolver'
+import { connectSchema } from './connect.schema'
+
+// ============================================================================
+// Schema Structure Tests
+// ============================================================================
+
+describe('connect.schema:structure', () => {
+ test('should define a mode field', () => {
+ const field = connectSchema.fields.mode
+ expect(field).toBeDefined()
+ expect(field.type).toBe('radio-list')
+ expect(field.defaultValue).toBe('framework')
+ const options = Array.isArray(field.options) ? field.options : []
+ expect(options.some((option) => option.value === 'framework')).toBe(true)
+ })
+})
+
+// ============================================================================
+// Field Definition Tests
+// ============================================================================
+
+describe('connect.schema:fields', () => {
+ test('framework field should have correct type', () => {
+ const field = connectSchema.fields.framework
+ expect(field.type).toBe('select')
+ expect(Array.isArray(field.options)).toBe(true)
+ const options = Array.isArray(field.options) ? field.options : []
+ expect(options.some((option) => option.value === 'nextjs')).toBe(true)
+ expect(field.defaultValue).toBe('nextjs')
+ expect(field.dependsOn).toEqual({ mode: ['framework'] })
+ })
+
+ test('frameworkVariant field should depend on framework', () => {
+ const field = connectSchema.fields.frameworkVariant
+ expect(field.dependsOn).toEqual({ mode: ['framework'], framework: ['nextjs', 'react'] })
+ expect(typeof field.options).toBe('function')
+ })
+
+ test('frameworkUi field should be a switch type', () => {
+ const field = connectSchema.fields.frameworkUi
+ expect(field.type).toBe('switch')
+ expect(field.defaultValue).toBe(false)
+ expect(field.dependsOn).toEqual({ mode: ['framework'], framework: ['nextjs', 'react'] })
+ })
+
+ test('connectionMethod field should be removed', () => {
+ const field = connectSchema.fields.connectionMethod
+ expect(field).toBeUndefined()
+ })
+
+ test('useSharedPooler field should be removed', () => {
+ const field = connectSchema.fields.useSharedPooler
+ expect(field).toBeUndefined()
+ })
+
+ test('orm field should be removed', () => {
+ const field = connectSchema.fields.orm
+ expect(field).toBeUndefined()
+ })
+
+ test('mcpClient field should be removed', () => {
+ const field = connectSchema.fields.mcpClient
+ expect(field).toBeUndefined()
+ })
+
+ test('mcpFeatures field should be removed', () => {
+ const field = connectSchema.fields.mcpFeatures
+ expect(field).toBeUndefined()
+ })
+})
+
+// ============================================================================
+// Install Commands Tests
+// ============================================================================
+
+describe('connect.schema:INSTALL_COMMANDS', () => {
+ test('should have install command for supabase-js', () => {
+ expect(INSTALL_COMMANDS.supabasejs).toBe('npm install @supabase/supabase-js')
+ })
+
+ test('should have install command for supabase-py', () => {
+ expect(INSTALL_COMMANDS.supabasepy).toBe('pip install supabase')
+ })
+
+ test('should have install command for supabase-flutter', () => {
+ expect(INSTALL_COMMANDS.supabaseflutter).toBe('flutter pub add supabase_flutter')
+ })
+
+ test('should have install command for supabase-swift', () => {
+ expect(INSTALL_COMMANDS.supabaseswift).toContain('swift package add-dependency')
+ })
+
+ test('should have install command for supabase-kt', () => {
+ expect(INSTALL_COMMANDS.supabasekt).toContain('io.github.jan-tennert.supabase')
+ })
+})
+
+// ============================================================================
+// Steps Resolution Integration Tests
+// ============================================================================
+
+describe('connect.schema:steps resolution', () => {
+ describe('framework mode steps', () => {
+ test('should resolve steps for nextjs without shadcn', () => {
+ const state: ConnectState = { mode: 'framework', framework: 'nextjs', frameworkUi: false }
+ const steps = resolveSteps(connectSchema, state)
+
+ expect(steps.length).toBeGreaterThan(0)
+ expect(steps.find((s) => s.id === 'install')).toBeDefined()
+ expect(steps.find((s) => s.id === 'install-skills')).toBeDefined()
+ })
+
+ test('should resolve shadcn steps for nextjs with frameworkUi true', () => {
+ const state: ConnectState = { mode: 'framework', framework: 'nextjs', frameworkUi: true }
+ const steps = resolveSteps(connectSchema, state)
+
+ expect(steps.find((s) => s.id === 'shadcn-add')).toBeDefined()
+ expect(steps.find((s) => s.id === 'shadcn-explore')).toBeDefined()
+ })
+
+ test('should resolve steps for react without shadcn', () => {
+ const state: ConnectState = { mode: 'framework', framework: 'react', frameworkUi: false }
+ const steps = resolveSteps(connectSchema, state)
+
+ expect(steps.length).toBeGreaterThan(0)
+ expect(steps.find((s) => s.id === 'install')).toBeDefined()
+ })
+
+ test('should resolve shadcn steps for react with frameworkUi true', () => {
+ const state: ConnectState = { mode: 'framework', framework: 'react', frameworkUi: true }
+ const steps = resolveSteps(connectSchema, state)
+
+ expect(steps.find((s) => s.id === 'shadcn-add')).toBeDefined()
+ })
+
+ test('should resolve default steps for other frameworks', () => {
+ const state: ConnectState = { mode: 'framework', framework: 'remix' }
+ const steps = resolveSteps(connectSchema, state)
+
+ expect(steps.length).toBeGreaterThan(0)
+ expect(steps.find((s) => s.id === 'install')).toBeDefined()
+ expect(steps.find((s) => s.id === 'configure')).toBeDefined()
+ })
+ })
+
+ describe('direct mode steps', () => {
+ test('should not resolve steps for direct mode', () => {
+ const state: ConnectState = { mode: 'direct' }
+ const steps = resolveSteps(connectSchema, state)
+
+ expect(steps.length).toBe(0)
+ })
+ })
+
+ describe('orm mode steps', () => {
+ test('should not resolve steps for orm mode', () => {
+ const state: ConnectState = { mode: 'orm', orm: 'prisma' }
+ const steps = resolveSteps(connectSchema, state)
+
+ expect(steps.length).toBe(0)
+ })
+ })
+
+ describe('mcp mode steps', () => {
+ test('should not resolve steps for mcp mode', () => {
+ const state: ConnectState = { mode: 'mcp', mcpClient: 'cursor' }
+ const steps = resolveSteps(connectSchema, state)
+
+ expect(steps.length).toBe(0)
+ })
+ })
+
+ describe('skills install step', () => {
+ test('should include skills install step in all modes', () => {
+ const modes: ConnectState['mode'][] = ['framework']
+
+ modes.forEach((mode) => {
+ const state: ConnectState = { mode }
+ const steps = resolveSteps(connectSchema, state)
+
+ expect(
+ steps.find((s) => s.id === 'install-skills'),
+ `Mode "${mode}" should have skills install step`
+ ).toBeDefined()
+ })
+ })
+ })
+})
+
+// ============================================================================
+// Step Content Path Tests
+// ============================================================================
+
+describe('connect.schema:step content paths', () => {
+ test('install step should have valid content path', () => {
+ const state: ConnectState = { mode: 'framework', framework: 'nextjs' }
+ const steps = resolveSteps(connectSchema, state)
+ const installStep = steps.find((s) => s.id === 'install')
+
+ expect(installStep?.content).toBe('steps/install')
+ })
+
+ test('shadcn command step should have valid content path', () => {
+ const state: ConnectState = { mode: 'framework', framework: 'nextjs', frameworkUi: true }
+ const steps = resolveSteps(connectSchema, state)
+ const shadcnStep = steps.find((s) => s.id === 'shadcn-add')
+
+ expect(shadcnStep?.content).toBe('steps/shadcn/command')
+ })
+
+ test('shadcn explore step should have valid content path', () => {
+ const state: ConnectState = { mode: 'framework', framework: 'nextjs', frameworkUi: true }
+ const steps = resolveSteps(connectSchema, state)
+ const exploreStep = steps.find((s) => s.id === 'shadcn-explore')
+
+ expect(exploreStep?.content).toBe('steps/shadcn/explore')
+ })
+
+ test('direct connection step should not be resolved', () => {
+ const state: ConnectState = { mode: 'direct' }
+ const steps = resolveSteps(connectSchema, state)
+
+ expect(steps.length).toBe(0)
+ })
+
+ test('skills install step should have valid content path', () => {
+ const state: ConnectState = { mode: 'framework' }
+ const steps = resolveSteps(connectSchema, state)
+ const skillsStep = steps.find((s) => s.id === 'install-skills')
+
+ expect(skillsStep?.content).toBe('steps/skills-install')
+ })
+
+ test('orm configure step should not be resolved', () => {
+ const state: ConnectState = { mode: 'orm', orm: 'prisma' }
+ const steps = resolveSteps(connectSchema, state)
+
+ expect(steps.length).toBe(0)
+ })
+
+ test('mcp cursor configure step should not be resolved', () => {
+ const state: ConnectState = { mode: 'mcp', mcpClient: 'cursor' }
+ const steps = resolveSteps(connectSchema, state)
+
+ expect(steps.length).toBe(0)
+ })
+
+ test('codex steps should not be resolved', () => {
+ const state: ConnectState = { mode: 'mcp', mcpClient: 'codex' }
+ const steps = resolveSteps(connectSchema, state)
+
+ expect(steps.length).toBe(0)
+ })
+
+ test('claude-code steps should not be resolved', () => {
+ const state: ConnectState = { mode: 'mcp', mcpClient: 'claude-code' }
+ const steps = resolveSteps(connectSchema, state)
+
+ expect(steps.length).toBe(0)
+ })
+})
diff --git a/apps/studio/components/interfaces/ConnectSheet/connect.schema.ts b/apps/studio/components/interfaces/ConnectSheet/connect.schema.ts
new file mode 100644
index 00000000000..ed4f9d83ee9
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/connect.schema.ts
@@ -0,0 +1,205 @@
+import { FRAMEWORKS, MOBILES } from './Connect.constants'
+import type { ConnectSchema, ConnectState, FieldOption, StepDefinition } from './Connect.types'
+
+const frameworkOptions: FieldOption[] = [...FRAMEWORKS, ...MOBILES].map((framework) => ({
+ value: framework.key,
+ label: framework.label,
+ icon: framework.icon,
+}))
+
+const modeOptions: FieldOption[] = [
+ {
+ value: 'framework',
+ label: 'Framework',
+ description: 'Use a client library',
+ },
+]
+
+const getFrameworkVariantOptions = (state: ConnectState): FieldOption[] => {
+ const allFrameworks = [...FRAMEWORKS, ...MOBILES]
+ const selected = allFrameworks.find((framework) => framework.key === state.framework)
+ if (!selected?.children?.length) return []
+ if (selected.children.length <= 1) return []
+
+ return selected.children.map((variant) => ({
+ value: variant.key,
+ label: variant.label,
+ icon: variant.icon,
+ }))
+}
+
+const getLibraryOptions = (state: ConnectState): FieldOption[] => {
+ const allFrameworks = [...FRAMEWORKS, ...MOBILES]
+ const selectedFramework = allFrameworks.find((framework) => framework.key === state.framework)
+ if (!selectedFramework) return []
+
+ if (selectedFramework.children?.length > 1 && state.frameworkVariant) {
+ const variant = selectedFramework.children.find((child) => child.key === state.frameworkVariant)
+ if (variant?.children?.length) {
+ return variant.children.map((child) => ({
+ value: child.key,
+ label: child.label,
+ icon: child.icon,
+ }))
+ }
+ }
+
+ if (selectedFramework.children?.length === 1) {
+ const child = selectedFramework.children[0]
+ if (child.children?.length) {
+ return child.children.map((library) => ({
+ value: library.key,
+ label: library.label,
+ icon: library.icon,
+ }))
+ }
+
+ return [{ value: child.key, label: child.label, icon: child.icon }]
+ }
+
+ return []
+}
+
+// ============================================================================
+// Step Definitions (reusable)
+// All content paths use template syntax: {{stateKey}} is replaced with state values
+// ============================================================================
+
+const frameworkInstallStep: StepDefinition = {
+ id: 'install',
+ title: 'Install package',
+ description: 'Run this command to install the required dependencies.',
+ content: 'steps/install',
+}
+
+const frameworkConfigureStep: StepDefinition = {
+ id: 'configure',
+ title: 'Add files',
+ description: 'Copy the following code into your project.',
+ content: '{{framework}}/{{frameworkVariant}}/{{library}}',
+}
+
+const frameworkNextJsFilesStep: StepDefinition = {
+ id: 'configure-nextjs',
+ title: 'Add files',
+ description:
+ 'Add env variables, create Supabase client helpers, and set up middleware to keep sessions refreshed.',
+ content: '{{framework}}/{{frameworkVariant}}/{{library}}',
+}
+
+const frameworkReactFilesStep: StepDefinition = {
+ id: 'configure-react',
+ title: 'Add files',
+ description: 'Add env variables, create a Supabase client, and use it in your app to query data.',
+ content: '{{framework}}/{{frameworkVariant}}/{{library}}',
+}
+
+const frameworkShadcnStep: StepDefinition = {
+ id: 'shadcn-add',
+ title: 'Add Supabase UI components',
+ description: 'Run this command to install the Supabase shadcn components.',
+ content: 'steps/shadcn/command',
+}
+
+const frameworkShadcnExploreStep: StepDefinition = {
+ id: 'shadcn-explore',
+ title: 'Check out more UI components',
+ description: 'Add auth, realtime and storage functionality to your project',
+ content: 'steps/shadcn/explore',
+}
+
+const skillsInstallStep: StepDefinition = {
+ id: 'install-skills',
+ title: 'Install Agent Skills (Optional)',
+ description:
+ 'Agent Skills give AI coding tools ready-made instructions, scripts, and resources for working with Supabase more accurately and efficiently.',
+ content: 'steps/skills-install',
+}
+
+// ============================================================================
+// Main Schema
+// ============================================================================
+
+export const connectSchema: ConnectSchema = {
+ // -------------------------------------------------------------------------
+ // Field Definitions
+ // -------------------------------------------------------------------------
+ fields: {
+ mode: {
+ id: 'mode',
+ type: 'radio-list',
+ label: 'Mode',
+ options: modeOptions,
+ defaultValue: 'framework',
+ },
+ // Framework fields
+ framework: {
+ id: 'framework',
+ type: 'select',
+ label: 'Framework',
+ options: frameworkOptions,
+ defaultValue: 'nextjs',
+ dependsOn: { mode: ['framework'] },
+ },
+ frameworkVariant: {
+ id: 'frameworkVariant',
+ type: 'select',
+ label: 'Variant',
+ options: getFrameworkVariantOptions,
+ defaultValue: 'vite',
+ dependsOn: { mode: ['framework'], framework: ['nextjs', 'react'] }, // Only show for frameworks with multiple variants
+ },
+ library: {
+ id: 'library',
+ type: 'select',
+ label: 'Library',
+ options: getLibraryOptions,
+ defaultValue: 'supabasejs',
+ dependsOn: { mode: ['framework'] },
+ },
+ frameworkUi: {
+ id: 'frameworkUi',
+ type: 'switch',
+ label: 'Shadcn',
+ description: 'Install components via the Supabase shadcn registry.',
+ defaultValue: false,
+ dependsOn: { mode: ['framework'], framework: ['nextjs', 'react'] },
+ },
+ },
+
+ // -------------------------------------------------------------------------
+ // Steps - Conditional based on mode and nested selections
+ // -------------------------------------------------------------------------
+ steps: {
+ // Keys are field IDs; each field maps state values to step trees.
+ mode: {
+ framework: {
+ framework: {
+ nextjs: {
+ frameworkUi: {
+ true: [
+ frameworkInstallStep,
+ frameworkShadcnStep,
+ frameworkShadcnExploreStep,
+ skillsInstallStep,
+ ],
+ DEFAULT: [frameworkInstallStep, frameworkNextJsFilesStep, skillsInstallStep],
+ },
+ },
+ react: {
+ frameworkUi: {
+ true: [
+ frameworkInstallStep,
+ frameworkShadcnStep,
+ frameworkShadcnExploreStep,
+ skillsInstallStep,
+ ],
+ DEFAULT: [frameworkInstallStep, frameworkReactFilesStep, skillsInstallStep],
+ },
+ },
+ DEFAULT: [frameworkInstallStep, frameworkConfigureStep, skillsInstallStep],
+ },
+ },
+ },
+ },
+}
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/androidkotlin/supabasekt/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/androidkotlin/supabasekt/content.tsx
new file mode 100644
index 00000000000..455506fce0f
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/androidkotlin/supabasekt/content.tsx
@@ -0,0 +1,71 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: 'MainActivity.kt',
+ language: 'kotlin',
+ code: `
+val supabase = createSupabaseClient(
+ supabaseUrl = "${projectKeys.apiUrl ?? 'your-project-url'}",
+ supabaseKey = "${projectKeys.publishableKey ?? '<prefer publishable key instead of anon key for mobile apps>'}"
+ ) {
+ install(Postgrest)
+}
+
+class MainActivity : ComponentActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContent {
+ MaterialTheme {
+ // A surface container using the 'background' color from the theme
+ Surface(
+ modifier = Modifier.fillMaxSize(),
+ color = MaterialTheme.colorScheme.background
+ ) {
+ TodoList()
+ }
+ }
+ }
+ }
+}
+
+@Composable
+fun TodoList() {
+ var items by remember { mutableStateOf<List<TodoItem>>(listOf()) }
+ LaunchedEffect(Unit) {
+ withContext(Dispatchers.IO) {
+ items = supabase.from("todos")
+ .select().decodeList<TodoItem>()
+ }
+ }
+ LazyColumn {
+ items(
+ items,
+ key = { item -> item.id },
+ ) { item ->
+ Text(
+ item.name,
+ modifier = Modifier.padding(8.dp),
+ )
+ }
+ }
+}
+`,
+ },
+ {
+ name: 'TodoItem.kt',
+ language: 'kotlin',
+ code: `
+@Serializable
+data class TodoItem(val id: Int, val name: String)
+ `,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/astro/supabasejs/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/astro/supabasejs/content.tsx
new file mode 100644
index 00000000000..f30bcf0cdd6
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/astro/supabasejs/content.tsx
@@ -0,0 +1,53 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: '.env.local',
+ language: 'bash',
+ code: `
+SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
+SUPABASE_KEY=${projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'}
+ `,
+ },
+ {
+ name: 'src/db/supabase.js',
+ language: 'js',
+ code: `
+import { createClient } from "@supabase/supabase-js";
+
+const supabaseUrl = import.meta.env.SUPABASE_URL;
+const supabaseKey = import.meta.env.SUPABASE_KEY;
+
+export const supabase = createClient(supabaseUrl, supabaseKey);
+ `,
+ },
+ {
+ name: 'src/pages/index.astro',
+ language: 'html',
+ code: `
+---
+import { supabase } from '../db/supabase';
+
+const { data, error } = await supabase.from("todos").select('*');
+---
+
+{
+ (
+ <ul>
+ {data.map((entry) => (
+ <li>{entry.name}</li>
+ ))}
+ </ul>
+ )
+}
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/exporeactnative/supabasejs/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/exporeactnative/supabasejs/content.tsx
new file mode 100644
index 00000000000..950e4759453
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/exporeactnative/supabasejs/content.tsx
@@ -0,0 +1,86 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: '.env.local',
+ language: 'bash',
+ code: `
+EXPO_PUBLIC_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
+EXPO_PUBLIC_SUPABASE_KEY=${projectKeys.publishableKey ?? '<prefer publishable key instead of anon key for mobile and desktop apps>'}
+ `,
+ },
+ {
+ name: 'utils/supabase.ts',
+ language: 'ts',
+ code: `
+import AsyncStorage from '@react-native-async-storage/async-storage'
+import { createClient } from '@supabase/supabase-js'
+
+export const supabase = createClient(
+ process.env.EXPO_PUBLIC_SUPABASE_URL!,
+ process.env.EXPO_PUBLIC_SUPABASE_KEY!,
+ {
+ auth: {
+ storage: AsyncStorage,
+ autoRefreshToken: true,
+ persistSession: true,
+ detectSessionInUrl: false,
+ },
+ })
+ `,
+ },
+ {
+ name: 'App.tsx',
+ language: 'tsx',
+ code: `
+import React, { useState, useEffect } from 'react';
+import { View, Text, FlatList } from 'react-native';
+import { supabase } from '../utils/supabase';
+
+export default function App() {
+ const [todos, setTodos] = useState([]);
+
+ useEffect(() => {
+ const getTodos = async () => {
+ try {
+ const { data: todos, error } = await supabase.from('todos').select();
+
+ if (error) {
+ console.error('Error fetching todos:', error.message);
+ return;
+ }
+
+ if (todos && todos.length > 0) {
+ setTodos(todos);
+ }
+ } catch (error) {
+ console.error('Error fetching todos:', error.message);
+ }
+ };
+
+ getTodos();
+ }, []);
+
+ return (
+ <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
+ <Text>Todo List</Text>
+ <FlatList
+ data={todos}
+ keyExtractor={(item) => item.id.toString()}
+ renderItem={({ item }) => <Text key={item.id}>{item.name}</Text>}
+ />
+ </View>
+ );
+};
+
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/flask/supabasepy/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/flask/supabasepy/content.tsx
new file mode 100644
index 00000000000..644ceb769e4
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/flask/supabasepy/content.tsx
@@ -0,0 +1,54 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: '.env',
+ language: 'bash',
+ code: `
+SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
+SUPABASE_KEY=${projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'}
+ `,
+ },
+ {
+ name: 'app.py',
+ language: 'python',
+ code: `
+import os
+from flask import Flask
+from supabase import create_client, Client
+from dotenv import load_dotenv
+
+load_dotenv()
+
+app = Flask(__name__)
+
+supabase: Client = create_client(
+ os.environ.get("SUPABASE_URL"),
+ os.environ.get("SUPABASE_KEY")
+)
+
+def index():
+ response = supabase.table('todos').select("*").execute()
+ todos = response.data
+
+ html = '<h1>Todos</h1><ul>'
+ for todo in todos:
+ html += f'<li>{todo["name"]}</li>'
+ html += '</ul>'
+
+ return html
+
+if __name__ == '__main__':
+ app.run(debug=True)
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/flutter/supabaseflutter/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/flutter/supabaseflutter/content.tsx
new file mode 100644
index 00000000000..90a7b36f2c4
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/flutter/supabaseflutter/content.tsx
@@ -0,0 +1,82 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: 'lib/main.dart',
+ language: 'dart',
+ code: `
+import 'package:flutter/material.dart';
+import 'package:supabase_flutter/supabase_flutter.dart';
+
+Future<void> main() async {
+ await Supabase.initialize(
+ url: '${projectKeys.apiUrl ?? 'your-project-url'}',
+ anonKey: '${projectKeys.publishableKey ?? '<prefer publishable key instead of anon key for mobile and desktop apps>'}',
+ );
+ runApp(MyApp());
+}
+ `,
+ },
+ {
+ name: 'lib/main.dart (app)',
+ language: 'dart',
+ code: `
+class MyApp extends StatelessWidget {
+ const MyApp({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ return const MaterialApp(
+ title: 'Todos',
+ home: HomePage(),
+ );
+ }
+}
+
+class HomePage extends StatefulWidget {
+ const HomePage({super.key});
+
+ @override
+ State<HomePage> createState() => _HomePageState();
+}
+
+class _HomePageState extends State<HomePage> {
+ final _future = Supabase.instance.client
+ .from('todos')
+ .select();
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ body: FutureBuilder(
+ future: _future,
+ builder: (context, snapshot) {
+ if (!snapshot.hasData) {
+ return const Center(child: CircularProgressIndicator());
+ }
+ final todos = snapshot.data!;
+ return ListView.builder(
+ itemCount: todos.length,
+ itemBuilder: ((context, index) {
+ final todo = todos[index];
+ return ListTile(
+ title: Text(todo['name']),
+ );
+ }),
+ );
+ },
+ ),
+ );
+ }
+}
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/ionicangular/supabasejs/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/ionicangular/supabasejs/content.tsx
new file mode 100644
index 00000000000..d1cd404f752
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/ionicangular/supabasejs/content.tsx
@@ -0,0 +1,127 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: 'environments/environment.ts',
+ language: 'ts',
+ code: `
+export const environment = {
+ supabaseUrl: '${projectKeys.apiUrl ?? 'your-project-url'}',
+ supabaseKey: '${projectKeys.publishableKey ?? '<prefer publishable key instead of anon key for mobile apps>'}',
+};
+`,
+ },
+ {
+ name: 'src/app/supabase.service.ts',
+ language: 'ts',
+ code: `
+import { Injectable } from '@angular/core';
+import { createClient, SupabaseClient } from '@supabase/supabase-js';
+import { environment } from '../environments/environment';
+
+@Injectable({
+ providedIn: 'root',
+})
+export class SupabaseService {
+ private supabase: SupabaseClient;
+ constructor() {
+ this.supabase = createClient(
+ environment.supabaseUrl,
+ environment.supabaseKey
+ );
+ }
+
+ getTodos() {
+ return this.supabase.from('todos').select('*');
+ }
+}
+`,
+ },
+ {
+ name: 'src/app/app.component.ts',
+ language: 'ts',
+ code: `
+import { Component, OnInit } from '@angular/core';
+import { SupabaseService } from './supabase.service';
+
+@Component({
+ selector: 'app-root',
+ templateUrl: 'app.component.html',
+ styleUrls: ['app.component.scss'],
+})
+export class AppComponent implements OnInit {
+ todos: any[] = [];
+
+ constructor(private supabaseService: SupabaseService) {}
+
+ async ngOnInit() {
+ await this.loadTodos();
+ }
+
+ async loadTodos() {
+ const { data, error } = await this.supabaseService.getTodos();
+ if (error) {
+ console.error('Error fetching todos:', error);
+ } else {
+ this.todos = data;
+ }
+ }
+}
+`,
+ },
+ {
+ name: 'src/app/app.component.html',
+ language: 'html',
+ code: `
+<ion-header>
+<ion-toolbar>
+ <ion-title>Todo List</ion-title>
+</ion-toolbar>
+</ion-header>
+
+<ion-content>
+<ion-list>
+ <ion-item *ngFor="let todo of todos">
+ <ion-label>{{ todo.name }}</ion-label>
+ </ion-item>
+</ion-list>
+</ion-content>
+`,
+ },
+ {
+ name: 'src/app/app.module.ts',
+ language: 'ts',
+ code: `
+import { NgModule } from '@angular/core';
+import { FormsModule } from '@angular/forms';
+import { BrowserModule } from '@angular/platform-browser';
+import { RouterModule } from '@angular/router';
+
+import { IonicModule } from '@ionic/angular';
+
+import { AppComponent } from './app.component';
+import { SupabaseService } from './supabase.service';
+
+@NgModule({
+ imports: [
+ BrowserModule,
+ FormsModule,
+ RouterModule.forRoot([]),
+ IonicModule.forRoot({ mode: 'ios' }),
+ ],
+ declarations: [AppComponent],
+ providers: [SupabaseService],
+ bootstrap: [AppComponent],
+})
+export class AppModule {}
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/ionicreact/supabasejs/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/ionicreact/supabasejs/content.tsx
new file mode 100644
index 00000000000..be4f077cd5f
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/ionicreact/supabasejs/content.tsx
@@ -0,0 +1,101 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: '.env',
+ language: 'bash',
+ code: `
+REACT_APP_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
+REACT_APP_SUPABASE_KEY=${projectKeys.publishableKey ?? '<prefer publishable key instead of anon key for mobile or desktop apps>'}
+ `,
+ },
+ {
+ name: 'src/supabaseClient.tsx',
+ language: 'ts',
+ code: `
+import { createClient } from '@supabase/supabase-js'
+
+const supabaseUrl = process.env.REACT_APP_SUPABASE_URL
+const supabaseAnonKey = process.env.REACT_APP_SUPABASE_KEY
+
+export const supabase = createClient(supabaseUrl, supabaseAnonKey)
+`,
+ },
+ {
+ name: 'src/App.tsx',
+ language: 'ts',
+ code: `
+import React, { useEffect, useState } from 'react';
+import { setupIonicReact, IonApp } from '@ionic/react';
+import {
+ IonContent,
+ IonHeader,
+ IonTitle,
+ IonToolbar,
+ IonList,
+ IonItem,
+} from '@ionic/react';
+
+/* Core CSS required for Ionic components to work properly */
+import '@ionic/react/css/core.css';
+
+/* Theme variables */
+import './theme/variables.css';
+
+import { supabase } from './supabaseClient';
+
+setupIonicReact();
+
+export default function App() {
+ const [todos, setTodos] = useState([]);
+ useEffect(() => {
+ getTodos();
+ }, []);
+
+ const getTodos = async () => {
+ try {
+ const { data, error } = await supabase.from('todos').select();
+
+ if (error) {
+ console.error('Error fetching todos:', error.message);
+ return;
+ }
+
+ if (data) {
+ setTodos(data);
+ }
+ } catch (error) {
+ console.error('Error fetching todos:', error.message);
+ }
+ };
+
+ return (
+ <IonApp>
+ <>
+ <IonHeader>
+ <IonToolbar>
+ <IonTitle>Todos</IonTitle>
+ </IonToolbar>
+ </IonHeader>
+ <IonContent>
+ <IonList>
+ {todos.map((todo) => (
+ <IonItem key={todo.id}>{todo.name}</IonItem>
+ ))}
+ </IonList>
+ </IonContent>
+ </>
+ </IonApp>
+ );
+}
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/nextjs/app/supabasejs/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/nextjs/app/supabasejs/content.tsx
new file mode 100644
index 00000000000..81821be6930
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/nextjs/app/supabasejs/content.tsx
@@ -0,0 +1,141 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: '.env.local',
+ language: 'bash',
+ code: [
+ `NEXT_PUBLIC_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
+ projectKeys?.publishableKey
+ ? `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY=${projectKeys.publishableKey}`
+ : `NEXT_PUBLIC_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
+ '',
+ ].join('\n'),
+ },
+ {
+ name: 'page.tsx',
+ language: 'tsx',
+ code: `
+import { createClient } from '@/utils/supabase/server'
+import { cookies } from 'next/headers'
+
+export default async function Page() {
+ const cookieStore = await cookies()
+ const supabase = createClient(cookieStore)
+
+ const { data: todos } = await supabase.from('todos').select()
+
+ return (
+ <ul>
+ {todos?.map((todo) => (
+ <li key={todo.id}>{todo.name}</li>
+ ))}
+ </ul>
+ )
+}
+`,
+ },
+ {
+ name: 'utils/supabase/server.ts',
+ language: 'ts',
+ code: `
+import { createServerClient } from "@supabase/ssr";
+import { cookies } from "next/headers";
+
+const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
+const supabaseKey = process.env.${projectKeys?.publishableKey ? 'NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY' : 'NEXT_PUBLIC_SUPABASE_ANON_KEY'};
+
+export const createClient = (cookieStore: Awaited<ReturnType<typeof cookies>>) => {
+ return createServerClient(
+ supabaseUrl!,
+ supabaseKey!,
+ {
+ cookies: {
+ getAll() {
+ return cookieStore.getAll()
+ },
+ setAll(cookiesToSet) {
+ try {
+ cookiesToSet.forEach(({ name, value, options }) => cookieStore.set(name, value, options))
+ } catch {
+ // The \`setAll\` method was called from a Server Component.
+ // This can be ignored if you have middleware refreshing
+ // user sessions.
+ }
+ },
+ },
+ },
+ );
+};
+`,
+ },
+ {
+ name: 'utils/supabase/client.ts',
+ language: 'ts',
+ code: `
+import { createBrowserClient } from "@supabase/ssr";
+
+const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
+const supabaseKey = process.env.${projectKeys?.publishableKey ? 'NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY' : 'NEXT_PUBLIC_SUPABASE_ANON_KEY'};
+
+export const createClient = () =>
+ createBrowserClient(
+ supabaseUrl!,
+ supabaseKey!,
+ );
+`,
+ },
+ {
+ name: 'utils/supabase/middleware.ts',
+ language: 'ts',
+ code: `
+import { createServerClient } from "@supabase/ssr";
+import { type NextRequest, NextResponse } from "next/server";
+
+const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
+const supabaseKey = process.env.${projectKeys?.publishableKey ? 'NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY' : 'NEXT_PUBLIC_SUPABASE_ANON_KEY'};
+
+export const createClient = (request: NextRequest) => {
+ // Create an unmodified response
+ let supabaseResponse = NextResponse.next({
+ request: {
+ headers: request.headers,
+ },
+ });
+
+ const supabase = createServerClient(
+ supabaseUrl!,
+ supabaseKey!,
+ {
+ cookies: {
+ getAll() {
+ return request.cookies.getAll()
+ },
+ setAll(cookiesToSet) {
+ cookiesToSet.forEach(({ name, value, options }) => request.cookies.set(name, value))
+ supabaseResponse = NextResponse.next({
+ request,
+ })
+ cookiesToSet.forEach(({ name, value, options }) =>
+ supabaseResponse.cookies.set(name, value, options)
+ )
+ },
+ },
+ },
+ );
+
+ return supabaseResponse
+};
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+// [Joshen] Used as a dynamic import
+// eslint-disable-next-line no-restricted-exports
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/nextjs/pages/supabasejs/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/nextjs/pages/supabasejs/content.tsx
new file mode 100644
index 00000000000..ce514b0ce4c
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/nextjs/pages/supabasejs/content.tsx
@@ -0,0 +1,67 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: '.env.local',
+ language: 'bash',
+ code: [
+ `NEXT_PUBLIC_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
+ projectKeys?.publishableKey
+ ? `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY=${projectKeys.publishableKey}`
+ : `NEXT_PUBLIC_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
+ '',
+ ].join('\n'),
+ },
+ {
+ name: 'utils/supabase.ts',
+ language: 'ts',
+ code: `
+import { createClient } from "@supabase/supabase-js";
+
+const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL!;
+const supabaseKey = process.env.${projectKeys?.publishableKey ? 'NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY' : 'NEXT_PUBLIC_SUPABASE_ANON_KEY'}!;
+
+export const supabase = createClient(supabaseUrl, supabaseKey);
+`,
+ },
+ {
+ name: 'pages/index.tsx',
+ language: 'tsx',
+ code: `
+import { useState, useEffect } from 'react'
+import { supabase } from '../utils/supabase'
+
+export default function Page() {
+ const [todos, setTodos] = useState([])
+
+ useEffect(() => {
+ async function getTodos() {
+ const { data: todos } = await supabase.from('todos').select()
+
+ if (todos) {
+ setTodos(todos)
+ }
+ }
+
+ getTodos()
+ }, [])
+
+ return (
+ <ul>
+ {todos.map((todo) => (
+ <li key={todo.id}>{todo.name}</li>
+ ))}
+ </ul>
+ )
+}
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/nuxt/supabasejs/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/nuxt/supabasejs/content.tsx
new file mode 100644
index 00000000000..08357299a13
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/nuxt/supabasejs/content.tsx
@@ -0,0 +1,65 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: '.env.local',
+ language: 'bash',
+ code: [
+ `SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
+ `SUPABASE_KEY=${projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'}`,
+ '',
+ ].join('\n'),
+ },
+ {
+ name: 'nuxt.config.ts',
+ language: 'ts',
+ code: `
+export default defineNuxtConfig({
+ runtimeConfig: {
+ public: {
+ supabaseUrl: process.env.SUPABASE_URL,
+ supabaseKey: process.env.SUPABASE_KEY,
+ },
+ },
+})
+`,
+ },
+ {
+ name: 'app.vue',
+ language: 'html',
+ code: `
+<script setup>
+import { ref, onMounted } from 'vue'
+import { createClient } from '@supabase/supabase-js'
+
+const config = useRuntimeConfig()
+const supabase = createClient(config.public.supabaseUrl, config.public.supabaseKey)
+
+const todos = ref([])
+
+async function getTodos() {
+ const { data } = await supabase.from('todos').select()
+ todos.value = data
+}
+
+onMounted(() => {
+ getTodos()
+})
+</script>
+
+<template>
+ <ul>
+ <li v-for="todo in todos" :key="todo.id">{{ todo.name }}</li>
+ </ul>
+</template>
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/react/create-react-app/supabasejs/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/react/create-react-app/supabasejs/content.tsx
new file mode 100644
index 00000000000..fb41c6b01be
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/react/create-react-app/supabasejs/content.tsx
@@ -0,0 +1,67 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: '.env.local',
+ language: 'bash',
+ code: [
+ `REACT_APP_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
+ projectKeys?.publishableKey
+ ? `REACT_APP_SUPABASE_PUBLISHABLE_DEFAULT_KEY=${projectKeys.publishableKey}`
+ : `REACT_APP_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
+ '',
+ ].join('\n'),
+ },
+ {
+ name: 'utils/supabase.ts',
+ language: 'ts',
+ code: `
+import { createClient } from "@supabase/supabase-js";
+
+const supabaseUrl = process.env.REACT_APP_SUPABASE_URL;
+const supabaseKey = process.env.${projectKeys.publishableKey ? 'REACT_APP_SUPABASE_PUBLISHABLE_DEFAULT_KEY' : 'REACT_APP_SUPABASE_ANON_KEY'};
+
+export const supabase = createClient(supabaseUrl, supabaseKey);
+ `,
+ },
+ {
+ name: 'App.tsx',
+ language: 'tsx',
+ code: `
+import { useState, useEffect } from 'react'
+import { supabase } from './utils/supabase'
+
+export default function App() {
+ const [todos, setTodos] = useState([])
+
+ useEffect(() => {
+ async function getTodos() {
+ const { data: todos } = await supabase.from('todos').select()
+
+ if (todos) {
+ setTodos(todos)
+ }
+ }
+
+ getTodos()
+ }, [])
+
+ return (
+ <ul>
+ {todos.map((todo) => (
+ <li key={todo.id}>{todo.name}</li>
+ ))}
+ </ul>
+ )
+}
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/react/vite/supabasejs/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/react/vite/supabasejs/content.tsx
new file mode 100644
index 00000000000..87ca660b40f
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/react/vite/supabasejs/content.tsx
@@ -0,0 +1,67 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: '.env',
+ language: 'bash',
+ code: [
+ `VITE_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
+ projectKeys?.publishableKey
+ ? `VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY=${projectKeys.publishableKey}`
+ : `VITE_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
+ '',
+ ].join('\n'),
+ },
+ {
+ name: 'utils/supabase.ts',
+ language: 'ts',
+ code: `
+import { createClient } from '@supabase/supabase-js';
+
+const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
+const supabaseKey = import.meta.env.${projectKeys.publishableKey ? 'VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY' : 'VITE_SUPABASE_ANON_KEY'};
+
+export const supabase = createClient(supabaseUrl, supabaseKey);
+`,
+ },
+ {
+ name: 'App.tsx',
+ language: 'tsx',
+ code: `
+import { useState, useEffect } from 'react'
+import { supabase } from './utils/supabase'
+
+export default function App() {
+ const [todos, setTodos] = useState([])
+
+ useEffect(() => {
+ async function getTodos() {
+ const { data: todos } = await supabase.from('todos').select()
+
+ if (todos) {
+ setTodos(todos)
+ }
+ }
+
+ getTodos()
+ }, [])
+
+ return (
+ <ul>
+ {todos.map((todo) => (
+ <li key={todo.id}>{todo.name}</li>
+ ))}
+ </ul>
+ )
+}
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/refine/supabasejs/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/refine/supabasejs/content.tsx
new file mode 100644
index 00000000000..97b65d09327
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/refine/supabasejs/content.tsx
@@ -0,0 +1,102 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: '.env.local',
+ language: 'bash',
+ code: [
+ `SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
+ `SUPABASE_KEY=${projectKeys?.publishableKey ?? projectKeys?.anonKey ?? 'your-anon-key'}`,
+ '',
+ ].join('\n'),
+ },
+ {
+ name: 'src/utility/supabaseClient.ts',
+ language: 'ts',
+ code: `
+import { createClient } from "@refinedev/supabase";
+
+const SUPABASE_URL = process.env.SUPABASE_URL;
+const SUPABASE_KEY = process.env.SUPABASE_KEY;
+
+export const supabaseClient = createClient(SUPABASE_URL, SUPABASE_KEY, {
+ db: {
+ schema: "public",
+ },
+ auth: {
+ persistSession: true,
+ },
+});
+ `,
+ },
+ {
+ name: 'src/App.tsx',
+ language: 'tsx',
+ code: `
+import { Refine } from "@refinedev/core";
+import { RefineKbar, RefineKbarProvider } from "@refinedev/kbar";
+import routerProvider, {
+ DocumentTitleHandler,
+ NavigateToResource,
+ UnsavedChangesNotifier,
+} from "@refinedev/react-router";
+import { dataProvider, liveProvider } from "@refinedev/supabase";
+import { BrowserRouter, Route, Routes } from "react-router-dom";
+
+import "./App.css";
+import authProvider from "./authProvider";
+import { supabaseClient } from "./utility";
+import { CountriesCreate, CountriesEdit, CountriesList, CountriesShow } from "./pages/countries";
+
+function App() {
+ return (
+ <BrowserRouter>
+ <RefineKbarProvider>
+ <Refine
+ dataProvider={dataProvider(supabaseClient)}
+ liveProvider={liveProvider(supabaseClient)}
+ authProvider={authProvider}
+ routerProvider={routerProvider}
+ options={{
+ syncWithLocation: true,
+ warnWhenUnsavedChanges: true,
+ }}
+ resources={[{
+ name: "countries",
+ list: "/countries",
+ create: "/countries/create",
+ edit: "/countries/edit/:id",
+ show: "/countries/show/:id"
+ }]}>
+ <Routes>
+ <Route index
+ element={<NavigateToResource resource="countries" />}
+ />
+ <Route path="/countries">
+ <Route index element={<CountriesList />} />
+ <Route path="create" element={<CountriesCreate />} />
+ <Route path="edit/:id" element={<CountriesEdit />} />
+ <Route path="show/:id" element={<CountriesShow />} />
+ </Route>
+ </Routes>
+ <RefineKbar />
+ <UnsavedChangesNotifier />
+ <DocumentTitleHandler />
+ </Refine>
+ </RefineKbarProvider>
+ </BrowserRouter>
+ );
+}
+
+export default App;
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/remix/supabasejs/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/remix/supabasejs/content.tsx
new file mode 100644
index 00000000000..d1bf8354bc7
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/remix/supabasejs/content.tsx
@@ -0,0 +1,91 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: '.env',
+ language: 'bash',
+ code: [
+ `VITE_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
+ projectKeys?.publishableKey
+ ? `VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY=${projectKeys.publishableKey}`
+ : `VITE_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
+ '',
+ ].join('\n'),
+ },
+ {
+ name: 'app/utils/supabase.server.ts',
+ language: 'ts',
+ code: `
+import {
+ createServerClient,
+ parseCookieHeader,
+ serializeCookieHeader,
+} from "@supabase/ssr";
+
+export function createClient(request: Request) {
+ const headers = new Headers();
+
+ const supabase = createServerClient(
+ process.env.VITE_SUPABASE_URL!,
+ process.env.VITE_${projectKeys.publishableKey ? 'SUPABASE_PUBLISHABLE_DEFAULT_KEY' : 'SUPABASE_ANON_KEY'},
+ {
+ cookies: {
+ getAll() {
+ return parseCookieHeader(request.headers.get("Cookie") ?? "") as {
+ name: string;
+ value: string;
+ }[];
+ },
+ setAll(cookiesToSet) {
+ cookiesToSet.forEach(({ name, value, options }) =>
+ headers.append(
+ "Set-Cookie",
+ serializeCookieHeader(name, value, options)
+ )
+ );
+ },
+ },
+ }
+ );
+
+ return { supabase, headers };
+}
+`,
+ },
+ {
+ name: 'app/routes/_index.tsx',
+ language: 'tsx',
+ code: `
+import type { Route } from "./+types/home";
+import { createClient } from "~/utils/supabase.server";
+
+export async function loader({ request }: Route.LoaderArgs) {
+ const { supabase } = createClient(request);
+ const { data: todos } = await supabase.from("todos").select();
+
+ return { todos };
+}
+
+export default function Home({ loaderData }: Route.ComponentProps) {
+ return (
+ <>
+ <ul>
+ {loaderData.todos?.map((todo) => (
+ <li key={todo.id}>{todo.name}</li>
+ ))}
+ </ul>
+ </>
+ );
+}
+
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/solidjs/supabasejs/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/solidjs/supabasejs/content.tsx
new file mode 100644
index 00000000000..c8a4608e348
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/solidjs/supabasejs/content.tsx
@@ -0,0 +1,60 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: '.env.local',
+ language: 'bash',
+ code: [
+ `VITE_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
+ projectKeys?.publishableKey
+ ? `VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY=${projectKeys.publishableKey}`
+ : `VITE_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
+ '',
+ ].join('\n'),
+ },
+ {
+ name: 'utils/supabase.ts',
+ language: 'ts',
+ code: `
+import { createClient } from "@supabase/supabase-js";
+
+const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
+const supabaseKey = import.meta.env.${projectKeys.publishableKey ? 'VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY' : 'VITE_SUPABASE_ANON_KEY'};
+
+export const supabase = createClient(supabaseUrl, supabaseKey);
+`,
+ },
+ {
+ name: 'src/App.tsx',
+ language: 'tsx',
+ code: `
+import { supabase } from '../utils/supabase'
+import { createResource, For } from "solid-js";
+
+async function getTodos() {
+ const { data: todos } = await supabase.from("todos").select();
+ return todos;
+}
+
+function App() {
+ const [todos] = createResource(getTodos);
+
+ return (
+ <ul>
+ <For each={todos()}>{(todo) => <li>{todo.name}</li>}</For>
+ </ul>
+ );
+}
+
+export default App;
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/steps/install/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/steps/install/content.tsx
new file mode 100644
index 00000000000..15d84d9a93a
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/steps/install/content.tsx
@@ -0,0 +1,54 @@
+import { Copy } from 'lucide-react'
+import { useMemo, useState } from 'react'
+import { Button, copyToClipboard } from 'ui'
+
+import { INSTALL_COMMANDS } from '../../../Connect.constants'
+import type { StepContentProps } from '../../../Connect.types'
+
+/**
+ * Gets the install command for the current framework selection.
+ */
+function getInstallCommand(state: StepContentProps['state']): string | null {
+ const libraryKey = typeof state.library === 'string' ? state.library : null
+
+ if (libraryKey && INSTALL_COMMANDS[libraryKey]) return INSTALL_COMMANDS[libraryKey]
+
+ return null
+}
+
+function InstallContent({ state }: StepContentProps) {
+ const installCommand = useMemo(() => getInstallCommand(state), [state])
+ const [copyLabel, setCopyLabel] = useState('Copy')
+
+ if (!installCommand) {
+ return null
+ }
+
+ const handleCopy = () => {
+ copyToClipboard(installCommand, () => {
+ setCopyLabel('Copied')
+ setTimeout(() => setCopyLabel('Copy'), 2000)
+ })
+ }
+
+ return (
+ <div className="relative group">
+ <div className="bg-surface-75 border rounded-lg p-3 pr-20 font-mono text-sm text-foreground-light overflow-x-auto">
+ <code>{installCommand}</code>
+ </div>
+ <div className="absolute right-2 top-1/2 -translate-y-1/2">
+ <Button
+ type="default"
+ size="tiny"
+ icon={<Copy size={14} />}
+ onClick={handleCopy}
+ className="opacity-0 group-hover:opacity-100 transition-opacity"
+ >
+ {copyLabel}
+ </Button>
+ </div>
+ </div>
+ )
+}
+
+export default InstallContent
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/steps/shadcn/command/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/steps/shadcn/command/content.tsx
new file mode 100644
index 00000000000..c8c15e50f90
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/steps/shadcn/command/content.tsx
@@ -0,0 +1,52 @@
+import { Copy } from 'lucide-react'
+import { useMemo, useState } from 'react'
+import { Button, copyToClipboard } from 'ui'
+
+import type { StepContentProps } from '../../../../Connect.types'
+
+function getShadcnCommand(state: StepContentProps['state']): string | null {
+ if (state.framework === 'nextjs') {
+ return 'npx shadcn@latest add @supabase/supabase-client-nextjs'
+ }
+
+ if (state.framework === 'react') {
+ return 'npx shadcn@latest add @supabase/supabase-client-react-router'
+ }
+
+ return null
+}
+
+function ShadcnCommandContent({ state }: StepContentProps) {
+ const command = useMemo(() => getShadcnCommand(state), [state])
+ const [copyLabel, setCopyLabel] = useState('Copy')
+
+ if (!command) return null
+
+ const handleCopy = () => {
+ copyToClipboard(command, () => {
+ setCopyLabel('Copied')
+ setTimeout(() => setCopyLabel('Copy'), 2000)
+ })
+ }
+
+ return (
+ <div className="relative group">
+ <div className="bg-surface-75 border rounded-lg p-3 pr-20 font-mono text-sm text-foreground-light overflow-x-auto">
+ <code>{command}</code>
+ </div>
+ <div className="absolute right-2 top-1/2 -translate-y-1/2">
+ <Button
+ type="default"
+ size="tiny"
+ icon={<Copy size={14} />}
+ onClick={handleCopy}
+ className="opacity-0 group-hover:opacity-100 transition-opacity"
+ >
+ {copyLabel}
+ </Button>
+ </div>
+ </div>
+ )
+}
+
+export default ShadcnCommandContent
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/steps/shadcn/explore/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/steps/shadcn/explore/content.tsx
new file mode 100644
index 00000000000..ee3d7210728
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/steps/shadcn/explore/content.tsx
@@ -0,0 +1,16 @@
+import { ExternalLink } from 'lucide-react'
+import { Button } from 'ui'
+
+import type { StepContentProps } from '../../../../Connect.types'
+
+function ShadcnExploreContent(_props: StepContentProps) {
+ return (
+ <Button asChild type="default" icon={<ExternalLink size={14} />}>
+ <a href="https://supabase.com/ui" target="_blank" rel="noreferrer">
+ Explore supabase.com/ui
+ </a>
+ </Button>
+ )
+}
+
+export default ShadcnExploreContent
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/steps/skills-install/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/steps/skills-install/content.tsx
new file mode 100644
index 00000000000..2a0bdfc8f83
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/steps/skills-install/content.tsx
@@ -0,0 +1,39 @@
+import { Copy } from 'lucide-react'
+import { useState } from 'react'
+import { Button, copyToClipboard } from 'ui'
+
+import type { StepContentProps } from '../../../Connect.types'
+
+const SKILLS_COMMAND = 'npx skills add supabase/agent-skills'
+
+function SkillsInstallContent(_props: StepContentProps) {
+ const [copyLabel, setCopyLabel] = useState('Copy')
+
+ const handleCopy = () => {
+ copyToClipboard(SKILLS_COMMAND, () => {
+ setCopyLabel('Copied')
+ setTimeout(() => setCopyLabel('Copy'), 2000)
+ })
+ }
+
+ return (
+ <div className="relative group">
+ <div className="bg-surface-75 border rounded-lg p-3 pr-20 font-mono text-sm text-foreground-light overflow-x-auto">
+ <code>{SKILLS_COMMAND}</code>
+ </div>
+ <div className="absolute right-2 top-1/2 -translate-y-1/2">
+ <Button
+ type="default"
+ size="tiny"
+ icon={<Copy size={14} />}
+ onClick={handleCopy}
+ className="opacity-0 group-hover:opacity-100 transition-opacity"
+ >
+ {copyLabel}
+ </Button>
+ </div>
+ </div>
+ )
+}
+
+export default SkillsInstallContent
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/sveltekit/supabasejs/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/sveltekit/supabasejs/content.tsx
new file mode 100644
index 00000000000..608c3e7f7b4
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/sveltekit/supabasejs/content.tsx
@@ -0,0 +1,65 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: '.env.local',
+ language: 'bash',
+ code: [
+ `PUBLIC_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
+ projectKeys?.publishableKey
+ ? `PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY=${projectKeys.publishableKey}`
+ : `PUBLIC_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
+ '',
+ ].join('\n'),
+ },
+ {
+ name: 'src/lib/supabaseClient.js',
+ language: 'js',
+ code: `
+import { createClient } from "@supabase/supabase-js";
+import { PUBLIC_SUPABASE_URL, ${projectKeys.publishableKey ? 'PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY' : 'PUBLIC_SUPABASE_ANON_KEY'} } from "$env/static/public"
+
+const supabaseUrl = PUBLIC_SUPABASE_URL;
+const supabaseKey = ${projectKeys.publishableKey ? 'PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY' : 'PUBLIC_SUPABASE_ANON_KEY'};
+
+export const supabase = createClient(supabaseUrl, supabaseKey);
+ `,
+ },
+ {
+ name: 'src/routes/+page.server.js',
+ language: 'js',
+ code: `
+import { supabase } from "$lib/supabaseClient";
+
+export async function load() {
+ const { data } = await supabase.from("countries").select();
+ return {
+ countries: data ?? [],
+ };
+}
+`,
+ },
+ {
+ name: 'src/routes/+page.svelte',
+ language: 'html',
+ code: `
+<script>
+ export let data;
+</script>
+
+<ul>
+ {#each data.countries as country}
+ <li>{country.name}</li>
+ {/each}
+</ul>
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/swift/supabaseswift/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/swift/supabaseswift/content.tsx
new file mode 100644
index 00000000000..d6054f6013e
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/swift/supabaseswift/content.tsx
@@ -0,0 +1,70 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: 'Supabase.swift',
+ language: 'swift',
+ code: `
+import Foundation
+import Supabase
+
+let supabase = SupabaseClient(
+ supabaseURL: URL(string: "${projectKeys.apiUrl ?? 'your-project-url'}")!,
+ supabaseKey: "${projectKeys.publishableKey ?? '<prefer publishable key for native apps instead of anon key>'}"
+)
+ `,
+ },
+ {
+ name: 'Todo.swift',
+ language: 'swift',
+ code: `
+import Foundation
+
+struct Todo: Identifiable, Decodable {
+ var id: Int
+ var name: String
+}
+`,
+ },
+ {
+ name: 'ContentView.swift',
+ language: 'swift',
+ code: `
+import Supabase
+import SwiftUI
+
+struct ContentView: View {
+ @State var todos: [Todo] = []
+
+ var body: some View {
+ NavigationStack {
+ List(todos) { todo in
+ Text(todo.name)
+ }
+ .navigationTitle("Todos")
+ .task {
+ do {
+ todos = try await supabase.from("todos").select().execute().value
+ } catch {
+ debugPrint(error)
+ }
+ }
+ }
+ }
+}
+
+#Preview {
+ ContentView()
+}
+
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/tanstack/supabasejs/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/tanstack/supabasejs/content.tsx
new file mode 100644
index 00000000000..cfe42dffbc5
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/tanstack/supabasejs/content.tsx
@@ -0,0 +1,60 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: '.env',
+ language: 'bash',
+ code: `
+VITE_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
+VITE_SUPABASE_KEY=${projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'}
+ `,
+ },
+ {
+ name: 'src/utils/supabase.ts',
+ language: 'ts',
+ code: `
+import { createClient } from "@supabase/supabase-js";
+
+export const supabase = createClient(
+ import.meta.env.VITE_SUPABASE_URL,
+ import.meta.env.VITE_SUPABASE_KEY
+);
+ `,
+ },
+ {
+ name: 'src/routes/index.tsx',
+ language: 'tsx',
+ code: `
+import { createFileRoute } from '@tanstack/react-router'
+import { supabase } from '../utils/supabase'
+
+export const Route = createFileRoute('/')({
+ loader: async () => {
+ const { data: todos } = await supabase.from('todos').select()
+ return { todos }
+ },
+ component: Home,
+})
+
+function Home() {
+ const { todos } = Route.useLoaderData()
+
+ return (
+ <ul>
+ {todos?.map((todo) => (
+ <li key={todo.id}>{todo.name}</li>
+ ))}
+ </ul>
+ )
+}
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/vuejs/supabasejs/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/vuejs/supabasejs/content.tsx
new file mode 100644
index 00000000000..b34cf8bacdc
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/vuejs/supabasejs/content.tsx
@@ -0,0 +1,63 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const files = [
+ {
+ name: '.env.local',
+ language: 'bash',
+ code: [
+ `VITE_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
+ projectKeys?.publishableKey
+ ? `VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY=${projectKeys.publishableKey}`
+ : `VITE_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
+ '',
+ ].join('\n'),
+ },
+ {
+ name: 'utils/supabase.ts',
+ language: 'ts',
+ code: `
+import { createClient } from "@supabase/supabase-js";
+
+const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
+const supabaseKey = import.meta.env.${projectKeys.publishableKey ? 'VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY' : 'VITE_SUPABASE_ANON_KEY'};
+
+export const supabase = createClient(supabaseUrl, supabaseKey);
+ `,
+ },
+ {
+ name: 'App.vue',
+ language: 'html',
+ code: `
+<script setup>
+ import { ref, onMounted } from 'vue'
+ import { supabase } from '../utils/supabase'
+
+ const todos = ref([])
+
+ async function getTodos() {
+ const { data } = await supabase.from('todos').select()
+ todos.value = data
+ }
+
+ onMounted(() => {
+ getTodos()
+ })
+
+</script>
+
+<template>
+ <ul>
+ <li v-for="todo in todos" :key="todo.id">{{ todo.name }}</li>
+ </ul>
+</template>
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/useConnectState.test.ts b/apps/studio/components/interfaces/ConnectSheet/useConnectState.test.ts
new file mode 100644
index 00000000000..652ea244b76
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/useConnectState.test.ts
@@ -0,0 +1,228 @@
+import { describe, test, expect } from 'vitest'
+import { renderHook, act } from '@testing-library/react'
+import { useConnectState } from './useConnectState'
+
+describe('useConnectState', () => {
+ // ============================================================================
+ // Initial State Tests
+ // ============================================================================
+
+ describe('initial state', () => {
+ test('should initialize with framework mode by default', () => {
+ const { result } = renderHook(() => useConnectState())
+ expect(result.current.state.mode).toBe('framework')
+ })
+
+ test('should initialize with nextjs as default framework', () => {
+ const { result } = renderHook(() => useConnectState())
+ expect(result.current.state.framework).toBe('nextjs')
+ })
+
+ test('should initialize with app variant for nextjs', () => {
+ const { result } = renderHook(() => useConnectState())
+ expect(result.current.state.frameworkVariant).toBe('app')
+ })
+
+ test('should initialize with supabasejs library', () => {
+ const { result } = renderHook(() => useConnectState())
+ expect(result.current.state.library).toBe('supabasejs')
+ })
+
+ test('should accept initial state override', () => {
+ const { result } = renderHook(() =>
+ useConnectState({ framework: 'react', frameworkVariant: 'vite' })
+ )
+ expect(result.current.state.mode).toBe('framework')
+ expect(result.current.state.framework).toBe('react')
+ expect(result.current.state.frameworkVariant).toBe('vite')
+ })
+
+ test('should merge initial state with defaults', () => {
+ const { result } = renderHook(() => useConnectState({ framework: 'react' }))
+ expect(result.current.state.mode).toBe('framework')
+ expect(result.current.state.framework).toBe('react')
+ })
+ })
+
+ // ============================================================================
+ // Field Update Tests
+ // ============================================================================
+
+ describe('updateField', () => {
+ test('should update framework selection', () => {
+ const { result } = renderHook(() => useConnectState())
+
+ act(() => {
+ result.current.updateField('framework', 'react')
+ })
+
+ expect(result.current.state.framework).toBe('react')
+ })
+
+ test('should cascade variant reset when changing framework', () => {
+ const { result } = renderHook(() => useConnectState())
+
+ // Start with nextjs which has variants
+ expect(result.current.state.frameworkVariant).toBe('app')
+
+ // Switch to a framework with multiple variants
+ act(() => {
+ result.current.updateField('framework', 'react')
+ })
+
+ // Should have the first variant of react
+ expect(result.current.state.frameworkVariant).toBeDefined()
+ })
+
+ test('should remove variant when switching to framework without variants', () => {
+ const { result } = renderHook(() => useConnectState())
+
+ // Start with nextjs which has variants
+ expect(result.current.state.frameworkVariant).toBe('app')
+
+ // Switch to remix which has no variants
+ act(() => {
+ result.current.updateField('framework', 'remix')
+ })
+
+ expect(result.current.state.frameworkVariant).toBeUndefined()
+ })
+
+ test('should update library when variant changes', () => {
+ const { result } = renderHook(() => useConnectState())
+
+ act(() => {
+ result.current.updateField('frameworkVariant', 'pages')
+ })
+
+ expect(result.current.state.library).toBe('supabasejs')
+ })
+
+ test('should update boolean fields', () => {
+ const { result } = renderHook(() => useConnectState())
+
+ act(() => {
+ result.current.updateField('frameworkUi', true)
+ })
+
+ expect(result.current.state.frameworkUi).toBe(true)
+ })
+ })
+
+ // ============================================================================
+ // Active Fields Tests
+ // ============================================================================
+
+ describe('activeFields', () => {
+ test('should return framework mode fields', () => {
+ const { result } = renderHook(() => useConnectState())
+
+ const fieldIds = result.current.activeFields.map((f) => f.id)
+ expect(fieldIds).toContain('framework')
+ })
+
+ test('should include variant field for nextjs', () => {
+ const { result } = renderHook(() => useConnectState({ framework: 'nextjs' }))
+
+ const fieldIds = result.current.activeFields.map((f) => f.id)
+ expect(fieldIds).toContain('frameworkVariant')
+ })
+
+ test('should include frameworkUi field for nextjs', () => {
+ const { result } = renderHook(() => useConnectState({ framework: 'nextjs' }))
+
+ const fieldIds = result.current.activeFields.map((f) => f.id)
+ expect(fieldIds).toContain('frameworkUi')
+ })
+
+ test('should not include frameworkUi for non-nextjs/react frameworks', () => {
+ const { result } = renderHook(() => useConnectState({ framework: 'remix' }))
+
+ const fieldIds = result.current.activeFields.map((f) => f.id)
+ expect(fieldIds).not.toContain('frameworkUi')
+ })
+ })
+
+ // ============================================================================
+ // Resolved Steps Tests
+ // ============================================================================
+
+ describe('resolvedSteps', () => {
+ test('should resolve steps for framework mode', () => {
+ const { result } = renderHook(() => useConnectState())
+
+ expect(result.current.resolvedSteps.length).toBeGreaterThan(0)
+ })
+
+ test('should have install step for framework mode', () => {
+ const { result } = renderHook(() => useConnectState())
+
+ const stepIds = result.current.resolvedSteps.map((s) => s.id)
+ expect(stepIds).toContain('install')
+ })
+
+ test('should include skills install step', () => {
+ const { result } = renderHook(() => useConnectState())
+
+ const stepIds = result.current.resolvedSteps.map((s) => s.id)
+ expect(stepIds).toContain('install-skills')
+ })
+
+ test('should resolve shadcn steps when frameworkUi is true', () => {
+ const { result } = renderHook(() =>
+ useConnectState({ framework: 'nextjs', frameworkUi: true })
+ )
+
+ const stepIds = result.current.resolvedSteps.map((s) => s.id)
+ expect(stepIds).toContain('shadcn-add')
+ })
+ })
+
+ // ============================================================================
+ // Field Options Tests
+ // ============================================================================
+
+ describe('getFieldOptions', () => {
+ test('should return framework options from schema', () => {
+ const { result } = renderHook(() => useConnectState())
+
+ const options = result.current.getFieldOptions('framework')
+ expect(options.some((o) => o.value === 'nextjs')).toBe(true)
+ expect(options.some((o) => o.value === 'react')).toBe(true)
+ })
+
+ test('should return empty array for inactive field', () => {
+ const { result } = renderHook(() => useConnectState({ framework: 'remix' }))
+
+ const options = result.current.getFieldOptions('frameworkVariant')
+ expect(options).toEqual([])
+ })
+
+ test('should return empty array for unknown field', () => {
+ const { result } = renderHook(() => useConnectState())
+
+ const options = result.current.getFieldOptions('unknownField')
+ expect(options).toEqual([])
+ })
+ })
+
+ // ============================================================================
+ // Schema Access Tests
+ // ============================================================================
+
+ describe('schema', () => {
+ test('should expose the connect schema', () => {
+ const { result } = renderHook(() => useConnectState())
+
+ expect(result.current.schema).toBeDefined()
+ expect(result.current.schema.fields).toBeDefined()
+ expect(result.current.schema.steps).toBeDefined()
+ })
+
+ test('should include mode field in schema', () => {
+ const { result } = renderHook(() => useConnectState())
+
+ expect(result.current.schema.fields.mode).toBeDefined()
+ })
+ })
+})
diff --git a/apps/studio/components/interfaces/ConnectSheet/useConnectState.ts b/apps/studio/components/interfaces/ConnectSheet/useConnectState.ts
new file mode 100644
index 00000000000..3135891b157
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/useConnectState.ts
@@ -0,0 +1,55 @@
+import { useCallback, useMemo, useState } from 'react'
+
+import { getActiveFields, resolveState, resolveSteps } from './connect.resolver'
+import { connectSchema } from './connect.schema'
+import type {
+ ConnectSchema,
+ ConnectState,
+ FieldOption,
+ ResolvedField,
+ ResolvedStep,
+} from './Connect.types'
+
+export interface UseConnectStateReturn {
+ state: ConnectState
+ updateField: (fieldId: string, value: string | boolean | string[]) => void
+ activeFields: ResolvedField[]
+ resolvedSteps: ResolvedStep[]
+ getFieldOptions: (fieldId: string) => FieldOption[]
+ schema: ConnectSchema
+}
+
+export function useConnectState(initialState?: Partial<ConnectState>): UseConnectStateReturn {
+ const [state, setState] = useState<ConnectState>(() => {
+ return resolveState(connectSchema, initialState ?? {})
+ })
+
+ const updateField = useCallback((fieldId: string, value: string | boolean | string[]) => {
+ setState((prev) => {
+ const next = { ...prev, [fieldId]: value }
+ return resolveState(connectSchema, next)
+ })
+ }, [])
+
+ const activeFields = useMemo(() => getActiveFields(connectSchema, state), [state])
+
+ const resolvedSteps = useMemo(() => resolveSteps(connectSchema, state), [state])
+
+ const getFieldOptions = useCallback(
+ (fieldId: string): FieldOption[] => {
+ const field = activeFields.find((f) => f.id === fieldId)
+ if (!field) return []
+ return field.resolvedOptions
+ },
+ [activeFields]
+ )
+
+ return {
+ state,
+ updateField,
+ activeFields,
+ resolvedSteps,
+ getFieldOptions,
+ schema: connectSchema,
+ }
+}
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx
index 3359ba6c7eb..08f9f317bf2 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx
@@ -10,6 +10,7 @@ import { OrganizationDropdown } from 'components/layouts/AppLayout/OrganizationD
import { ProjectDropdown } from 'components/layouts/AppLayout/ProjectDropdown'
import { getResourcesExceededLimitsOrg } from 'components/ui/OveragesBanner/OveragesBanner.utils'
import { useOrgUsageQuery } from 'data/usage/org-usage-query'
+import { DevToolbarTrigger } from 'dev-tools'
import { AnimatePresence, motion } from 'framer-motion'
import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
@@ -22,7 +23,7 @@ import { ReactNode, useMemo } from 'react'
import { useAppStateSnapshot } from 'state/app-state'
import { Badge, cn } from 'ui'
import { CommandMenuTriggerInput } from 'ui-patterns'
-import { DevToolbarTrigger } from 'dev-tools'
+
import { BreadcrumbsView } from './BreadcrumbsView'
import { FeedbackDropdown } from './FeedbackDropdown/FeedbackDropdown'
import { HelpDropdown } from './HelpDropdown/HelpDropdown'
@@ -274,7 +275,7 @@ export const LayoutHeader = ({
</div>
</header>
- {isFlagResolved && isConnectSheetEnabled ? <ConnectSheet /> : <Connect />}
+ {isFlagResolved ? isConnectSheetEnabled ? <ConnectSheet /> : <Connect /> : null}
</>
)
}
diff --git a/apps/studio/hooks/ui/useFlag.ts b/apps/studio/hooks/ui/useFlag.ts
index 55f9704f0eb..3a72a29d848 100644
--- a/apps/studio/hooks/ui/useFlag.ts
+++ b/apps/studio/hooks/ui/useFlag.ts
@@ -1,6 +1,5 @@
import * as Sentry from '@sentry/nextjs'
-
-import { useFeatureFlags } from 'common'
+import { IS_PLATFORM, useFeatureFlags } from 'common'
import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
import { trackFeatureFlag } from 'lib/posthog'
@@ -42,6 +41,8 @@ export function usePHFlag<T = string | boolean>(name: string) {
const store = flagStore.posthog
const flagValue = store[name]
+ if (!IS_PLATFORM) return false
+
// Flag store has not been initialized
if (isObjectEmpty(store)) return undefined
diff --git a/apps/studio/pages/project/[ref]/index.tsx b/apps/studio/pages/project/[ref]/index.tsx
index a28d4c452dd..a81026a90f4 100644
--- a/apps/studio/pages/project/[ref]/index.tsx
+++ b/apps/studio/pages/project/[ref]/index.tsx
@@ -11,7 +11,10 @@ const HomePage: NextPageWithLayout = () => {
const homeNewVariant = usePHFlag<string>('homeNew')
const isHomeNew = homeNewVariant === 'new-home'
- useTrackExperimentExposure('home_new', IS_PLATFORM ? homeNewVariant : undefined)
+ useTrackExperimentExposure(
+ 'home_new',
+ IS_PLATFORM && typeof homeNewVariant !== 'boolean' ? homeNewVariant : undefined
+ )
if (isHomeNew) {
return <HomeV2 />
diff --git a/packages/ui-patterns/package.json b/packages/ui-patterns/package.json
index 33465589fc3..8368eb6fb61 100644
--- a/packages/ui-patterns/package.json
+++ b/packages/ui-patterns/package.json
@@ -582,6 +582,10 @@
"import": "./src/admonition.tsx",
"types": "./src/admonition.tsx"
},
+ "./MultipleCodeBlock": {
+ "import": "./src/MultipleCodeBlock/index.tsx",
+ "types": "./src/MultipleCodeBlock/index.tsx"
+ },
"./consent": {
"import": "./src/consent.tsx",
"types": "./src/consent.tsx"
diff --git a/packages/ui-patterns/src/MultipleCodeBlock/index.tsx b/packages/ui-patterns/src/MultipleCodeBlock/index.tsx
new file mode 100644
index 00000000000..f9bb257ca1e
--- /dev/null
+++ b/packages/ui-patterns/src/MultipleCodeBlock/index.tsx
@@ -0,0 +1,148 @@
+import {
+ CodeBlock,
+ CodeBlockLang,
+ TabsContent_Shadcn_,
+ TabsList_Shadcn_,
+ TabsTrigger_Shadcn_,
+ Tabs_Shadcn_,
+} from 'ui'
+
+interface MultipleCodeBlockFile {
+ name: string
+ code: string
+ language?: string
+}
+
+interface MultipleCodeBlockProps {
+ files: MultipleCodeBlockFile[]
+ value?: string
+ onValueChange?: (value: string) => void
+}
+
+const languageAliases: Record<string, CodeBlockLang> = {
+ bash: 'bash',
+ csharp: 'csharp',
+ cs: 'csharp',
+ curl: 'curl',
+ dart: 'dart',
+ go: 'go',
+ http: 'http',
+ javascript: 'js',
+ js: 'js',
+ json: 'json',
+ jsx: 'jsx',
+ kotlin: 'kotlin',
+ pgsql: 'pgsql',
+ php: 'php',
+ py: 'python',
+ python: 'python',
+ sh: 'bash',
+ shell: 'bash',
+ sql: 'sql',
+ swift: 'swift',
+ ts: 'ts',
+ typescript: 'ts',
+ yaml: 'yaml',
+ yml: 'yaml',
+}
+
+const extensionLanguageMap: Record<string, CodeBlockLang> = {
+ astro: 'html',
+ bash: 'bash',
+ cjs: 'js',
+ dart: 'dart',
+ go: 'go',
+ js: 'js',
+ json: 'json',
+ jsx: 'jsx',
+ kt: 'kotlin',
+ mjs: 'js',
+ php: 'php',
+ pgsql: 'pgsql',
+ py: 'python',
+ sh: 'bash',
+ sql: 'sql',
+ swift: 'swift',
+ svelte: 'html',
+ ts: 'ts',
+ vue: 'html',
+ yaml: 'yaml',
+ yml: 'yaml',
+}
+
+const inferLanguageFromName = (name: string): CodeBlockLang | undefined => {
+ const lowerName = name.toLowerCase()
+ if (lowerName.startsWith('.env')) {
+ return 'bash'
+ }
+
+ const extension = lowerName.split('.').pop()
+ if (!extension || extension === lowerName) {
+ return undefined
+ }
+
+ return extensionLanguageMap[extension]
+}
+
+const resolveLanguage = (language: string | undefined, name: string): CodeBlockLang => {
+ if (language) {
+ const normalized = language.toLowerCase()
+ const resolved = languageAliases[normalized]
+ if (resolved) {
+ return resolved
+ }
+ }
+
+ return inferLanguageFromName(name) ?? 'js'
+}
+
+export const MultipleCodeBlock = ({ files, value, onValueChange }: MultipleCodeBlockProps) => {
+ if (!files?.length) {
+ return null
+ }
+
+ const defaultValue = files[0]?.name ?? ''
+
+ const trimmedFiles = files.map((file) => ({
+ ...file,
+ code: typeof file.code === 'string' ? file.code.trim() : file.code,
+ }))
+
+ return (
+ <Tabs_Shadcn_
+ defaultValue={defaultValue}
+ value={value}
+ onValueChange={onValueChange}
+ className="border rounded-lg gap-0 space-y-0 overflow-hidden"
+ >
+ <TabsList_Shadcn_ className="bg-surface-75 px-5 gap-5 overflow-x-auto border-0 border-b">
+ {files.map((file) => (
+ <TabsTrigger_Shadcn_
+ key={file.name}
+ value={file.name}
+ className="flex items-center gap-1 text-xs px-0 data-[state=active]:bg-transparent py-2.5"
+ >
+ {file.name}
+ </TabsTrigger_Shadcn_>
+ ))}
+ </TabsList_Shadcn_>
+
+ {trimmedFiles.map((file) => (
+ <TabsContent_Shadcn_
+ key={file.name}
+ value={file.name}
+ forceMount
+ className="p-0 max-h-72 overflow-scroll data-[state=inactive]:hidden"
+ data-connect-tab-content
+ data-tab-label={file.name}
+ >
+ <CodeBlock
+ value={typeof file.code === 'string' ? file.code.trim() : file.code}
+ language={resolveLanguage(file.language, file.name)}
+ className="min-h-72 !bg-surface-75 rounded-none border-0"
+ />
+ </TabsContent_Shadcn_>
+ ))}
+ </Tabs_Shadcn_>
+ )
+}
diff --git a/packages/ui/src/components/CodeBlock/CodeBlock.tsx b/packages/ui/src/components/CodeBlock/CodeBlock.tsx
index 6d411ac5686..53708330206 100644
--- a/packages/ui/src/components/CodeBlock/CodeBlock.tsx
+++ b/packages/ui/src/components/CodeBlock/CodeBlock.tsx
@@ -11,6 +11,7 @@ import csharp from 'react-syntax-highlighter/dist/cjs/languages/hljs/csharp'
import dart from 'react-syntax-highlighter/dist/cjs/languages/hljs/dart'
import go from 'react-syntax-highlighter/dist/cjs/languages/hljs/go'
import http from 'react-syntax-highlighter/dist/cjs/languages/hljs/http'
+import ini from 'react-syntax-highlighter/dist/cjs/languages/hljs/ini'
import js from 'react-syntax-highlighter/dist/cjs/languages/hljs/javascript'
import json from 'react-syntax-highlighter/dist/cjs/languages/hljs/json'
import kotlin from 'react-syntax-highlighter/dist/cjs/languages/hljs/kotlin'
@@ -21,7 +22,9 @@ import {
default as python,
} from 'react-syntax-highlighter/dist/cjs/languages/hljs/python'
import sql from 'react-syntax-highlighter/dist/cjs/languages/hljs/sql'
+import swift from 'react-syntax-highlighter/dist/cjs/languages/hljs/swift'
import ts from 'react-syntax-highlighter/dist/cjs/languages/hljs/typescript'
+import xml from 'react-syntax-highlighter/dist/cjs/languages/hljs/xml'
import yaml from 'react-syntax-highlighter/dist/cjs/languages/hljs/yaml'
import { copyToClipboard } from '../../lib/utils'
@@ -46,7 +49,10 @@ export type CodeBlockLang =
| 'python'
| 'go'
| 'pgsql'
+ | 'swift'
| 'yaml'
+ | 'toml'
+ | 'html'
export interface CodeBlockProps {
title?: ReactNode
@@ -159,6 +165,9 @@ export const CodeBlock = ({
SyntaxHighlighter.registerLanguage('python', python)
SyntaxHighlighter.registerLanguage('go', go)
SyntaxHighlighter.registerLanguage('pgsql', pgsql)
+ SyntaxHighlighter.registerLanguage('swift', swift)
+ SyntaxHighlighter.registerLanguage('html', xml)
+ SyntaxHighlighter.registerLanguage('toml', ini)
SyntaxHighlighter.registerLanguage('yaml', yaml)
const large = false