Skip to content

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

chore: dead code cleanup, remove old connect components (#47122)

Gildas Garcia0645dd4ba108
diff --git a/apps/studio/components/interfaces/Connect/ApiKeysTabContent.tsx b/apps/studio/components/interfaces/Connect/ApiKeysTabContent.tsx
deleted file mode 100644
index 3e86a84e078..00000000000
--- a/apps/studio/components/interfaces/Connect/ApiKeysTabContent.tsx
+++ /dev/null
@@ -1,76 +0,0 @@
-import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { useParams } from 'common'
-import { AlertCircle, ExternalLink, Loader2 } from 'lucide-react'
-import Link from 'next/link'
-import type { ReactNode } from 'react'
-import { Button } from 'ui'
-import { Input } from 'ui-patterns/DataInputs/Input'
-
-import type { projectKeys } from './Connect.types'
-import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
-
-function KeyRow({ label, value }: { label: ReactNode; value: string }) {
- return (
- <div className="flex flex-col gap-5 lg:grid lg:grid-cols-12">
- <div className="col-span-4">
- <h3 className="text-sm text-foreground">{label}</h3>
- </div>
- <div className="col-span-8">
- <Input readOnly copy className="font-mono" value={value} />
- </div>
- </div>
- )
-}
-
-export function ApiKeysTabContent({ projectKeys }: { projectKeys: projectKeys }) {
- const { ref: projectRef } = useParams()
-
- const { isLoading: isLoadingPermissions, can: canReadAPIKeys } = useAsyncCheckPermissions(
- PermissionAction.SECRETS_READ,
- '*'
- )
-
- if (isLoadingPermissions) {
- return (
- <div className="flex items-center justify-center py-8 space-x-2">
- <Loader2 className="animate-spin" size={16} strokeWidth={1.5} />
- <p className="text-sm text-foreground-light">Retrieving API keys</p>
- </div>
- )
- }
-
- if (!canReadAPIKeys) {
- return (
- <div className="flex items-center py-8 space-x-2">
- <AlertCircle size={16} strokeWidth={1.5} />
- <p className="text-sm text-foreground-light">You don't have permission to view API keys.</p>
- </div>
- )
- }
-
- return (
- <div className="flex flex-col gap-8">
- <KeyRow label="Project URL" value={projectKeys.apiUrl ?? ''} />
-
- <KeyRow label="Publishable Key" value={projectKeys.publishableKey ?? ''} />
-
- <KeyRow
- label={
- <>
- Anon Key <span className="text-foreground-lighter font-normal">(Legacy)</span>
- </>
- }
- value={projectKeys.anonKey ?? ''}
- />
-
- <div className="gap-5 lg:grid lg:grid-cols-12">
- <div className="col-start-5 col-span-8 pl-2 flex items-center justify-between">
- <p className="text-xs text-foreground-lighter">For secret keys, see API settings.</p>
- <Button asChild variant="default" icon={<ExternalLink size={14} />}>
- <Link href={`/project/${projectRef}/settings/api-keys`}>API settings</Link>
- </Button>
- </div>
- </div>
- </div>
- )
-}
diff --git a/apps/studio/components/interfaces/Connect/Connect.constants.ts b/apps/studio/components/interfaces/Connect/Connect.constants.ts
deleted file mode 100644
index 6b71f1e8229..00000000000
--- a/apps/studio/components/interfaces/Connect/Connect.constants.ts
+++ /dev/null
@@ -1,414 +0,0 @@
-import { type CodeBlockLang } from 'ui-patterns/CodeBlock'
-
-import { DOCS_URL } from '@/lib/constants'
-
-export type DatabaseConnectionType =
- | 'uri'
- | 'psql'
- | 'golang'
- | 'jdbc'
- | 'dotnet'
- | 'nodejs'
- | 'php'
- | 'python'
- | 'sqlalchemy'
-
-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: 'React Router',
- 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: 'api-keys', label: 'API Keys', obj: [] },
- { 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/Connect/Connect.types.ts b/apps/studio/components/interfaces/Connect/Connect.types.ts
deleted file mode 100644
index d75a5df614d..00000000000
--- a/apps/studio/components/interfaces/Connect/Connect.types.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-export type projectKeys = {
- apiUrl: string | null
- anonKey: string | null
- publishableKey: string | null
-}
-
-export interface ContentFileProps {
- projectKeys: {
- apiUrl: string
- anonKey?: string
- publishableKey?: string
- }
- connectionStringPooler: {
- transactionShared: string
- sessionShared: string
- transactionDedicated?: string
- sessionDedicated?: string
- ipv4SupportedForDedicatedPooler: boolean
- direct?: string
- }
- connectionTab: 'App Frameworks' | 'Mobile Frameworks' | 'ORMs'
- onCopy?: () => void
-}
diff --git a/apps/studio/components/interfaces/Connect/Connect.utils.ts b/apps/studio/components/interfaces/Connect/Connect.utils.ts
deleted file mode 100644
index 885604d1896..00000000000
--- a/apps/studio/components/interfaces/Connect/Connect.utils.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-import { ConnectionType, FRAMEWORKS, MOBILES, ORMS } from './Connect.constants'
-
-export function getProjectRef(url: string): string | null {
- const regex: RegExp = /https:\/\/([^\.]+)\./
- const match: RegExpMatchArray | null = url.match(regex)
-
- if (match) {
- return match[1]
- } else {
- return null
- }
-}
-
-export const getContentFilePath = ({
- connectionObject,
- selectedParent,
- selectedChild,
- selectedGrandchild,
-}: {
- selectedParent: string
- selectedChild: string
- selectedGrandchild: string
- connectionObject: ConnectionType[]
-}) => {
- const parent = connectionObject.find((item) => item.key === selectedParent)
-
- if (parent) {
- const child = parent.children.find((child) => child.key === selectedChild)
-
- // check grandchild first, then child, then parent as the fallback
- if (child) {
- const grandchild = child.children.find((grandchild) => grandchild.key === selectedGrandchild)
-
- if (grandchild) {
- return `${selectedParent}/${selectedChild}/${selectedGrandchild}`
- } else {
- return `${selectedParent}/${selectedChild}`
- }
- } else {
- return selectedParent
- }
- }
-
- return ''
-}
-
-export function inferConnectTabFromParentKey(
- parentKey: string | null
-): 'frameworks' | 'mobiles' | 'orms' | null {
- if (!parentKey) return null
- if (FRAMEWORKS.find((x: ConnectionType) => x.key === parentKey)) return 'frameworks'
- if (MOBILES.find((x: ConnectionType) => x.key === parentKey)) return 'mobiles'
- if (ORMS.find((x: ConnectionType) => x.key === parentKey)) return 'orms'
- return null
-}
diff --git a/apps/studio/components/interfaces/Connect/ConnectDropdown.tsx b/apps/studio/components/interfaces/Connect/ConnectDropdown.tsx
deleted file mode 100644
index e56f50097a8..00000000000
--- a/apps/studio/components/interfaces/Connect/ConnectDropdown.tsx
+++ /dev/null
@@ -1,113 +0,0 @@
-import { Box, Check, ChevronDown } from 'lucide-react'
-import { useState } from 'react'
-import {
- Button,
- cn,
- Command,
- CommandEmpty,
- CommandGroup,
- CommandInput,
- CommandItem,
- CommandList,
- Popover,
- PopoverContent,
- PopoverTrigger,
-} from 'ui'
-
-import { ConnectionType } from './Connect.constants'
-import { ConnectionIcon } from './ConnectionIcon'
-
-interface ConnectDropdownProps {
- state: string
- updateState: (state: string) => void
- label: string
- items: ConnectionType[]
- iconFolder?: string
- supportsDarkMode?: boolean
-}
-
-export const ConnectDropdown = ({
- state,
- updateState,
- label,
-
- items,
- iconFolder,
- supportsDarkMode,
-}: ConnectDropdownProps) => {
- const [open, setOpen] = useState(false)
-
- function onSelectLib(key: string) {
- updateState(key)
- setOpen(false)
- }
-
- const selectedItem = items.find((item) => item.key === state)
-
- return (
- <Popover open={open} onOpenChange={setOpen} modal={false}>
- <div className="flex ">
- <span className="flex items-center text-foreground-lighter px-3 rounded-lg rounded-r-none text-xs border border-button border-r-0">
- {label}
- </span>
- <PopoverTrigger asChild>
- <Button
- size="small"
- variant="default"
- className="gap-0 rounded-l-none"
- iconRight={<ChevronDown strokeWidth={1.5} />}
- >
- <div className="flex items-center gap-2">
- {selectedItem?.icon ? (
- <ConnectionIcon
- icon={selectedItem.icon}
- iconFolder={iconFolder}
- supportsDarkMode={supportsDarkMode}
- />
- ) : (
- <Box size={12} />
- )}
- {selectedItem?.label}
- </div>
- </Button>
- </PopoverTrigger>
- </div>
- <PopoverContent className="p-0 max-w-48" side="bottom" align="start">
- <Command>
- <CommandInput placeholder="Search..." />
- <CommandList>
- <CommandEmpty>No results found.</CommandEmpty>
- <CommandGroup>
- {items.map((item) => (
- <CommandItem
- key={item.key}
- value={item.key}
- onSelect={() => {
- onSelectLib(item.key)
- setOpen(false)
- }}
- className="flex gap-2 items-center"
- >
- {item.icon ? (
- <ConnectionIcon
- icon={item.icon}
- iconFolder={iconFolder}
- supportsDarkMode={supportsDarkMode}
- />
- ) : (
- <Box size={12} />
- )}
- {item.label}
- <Check
- size={15}
- className={cn('ml-auto ', item.key === state ? 'opacity-100' : 'opacity-0')}
- />
- </CommandItem>
- ))}
- </CommandGroup>
- </CommandList>
- </Command>
- </PopoverContent>
- </Popover>
- )
-}
diff --git a/apps/studio/components/interfaces/Connect/ConnectTabContent.tsx b/apps/studio/components/interfaces/Connect/ConnectTabContent.tsx
deleted file mode 100644
index e3ba0beda3f..00000000000
--- a/apps/studio/components/interfaces/Connect/ConnectTabContent.tsx
+++ /dev/null
@@ -1,133 +0,0 @@
-import { useParams } from 'common'
-import dynamic from 'next/dynamic'
-import { forwardRef, HTMLAttributes, useMemo } from 'react'
-import { cn } from 'ui'
-import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
-import { CopyCallbackContext } from 'ui-patterns/SimpleCodeBlock'
-
-import { getAddons } from '../Billing/Subscription/Subscription.utils'
-import type { projectKeys } from './Connect.types'
-import { getConnectionStrings } from './DatabaseSettings.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 { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'
-import { pluckObjectFields } from '@/lib/helpers'
-import { useTrack } from '@/lib/telemetry/track'
-
-interface ConnectContentTabProps extends HTMLAttributes<HTMLDivElement> {
- projectKeys: projectKeys
- filePath: string
- connectionTab: 'App Frameworks' | 'Mobile Frameworks' | 'ORMs'
- selectedFrameworkOrTool: string
- connectionStringPooler?: {
- transactionShared: string
- sessionShared: string
- transactionDedicated?: string
- sessionDedicated?: string
- ipv4SupportedForDedicatedPooler: boolean
- direct?: string
- }
-}
-
-export const ConnectTabContent = forwardRef<HTMLDivElement, ConnectContentTabProps>(
- ({ projectKeys, filePath, connectionTab, selectedFrameworkOrTool, ...props }, ref) => {
- const { ref: projectRef } = useParams()
- const track = useTrack()
- const { hasAccess: allowPgBouncerSelection } = useCheckEntitlements('dedicated_pooler')
-
- const handleCopy = () => {
- const trackingProperties: {
- connectionTab: 'App Frameworks' | 'Mobile Frameworks' | 'ORMs'
- selectedItem: string
- connectionType?: string
- lang?: string
- } = {
- connectionTab,
- selectedItem: selectedFrameworkOrTool,
- }
-
- // Only include connectionType and lang for App Frameworks and Mobile Frameworks
- if (connectionTab !== 'ORMs') {
- trackingProperties.connectionType = 'Framework snippet'
- trackingProperties.lang = filePath.split('/').pop() ?? 'unknown'
- }
-
- track('connection_string_copied', trackingProperties)
- }
-
- 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 connectionStringsShared = getConnectionStrings({
- 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 connectionStringsDedicated =
- poolingConfigurationDedicated !== undefined
- ? getConnectionStrings({
- 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
-
- const ContentFile = useMemo(() => {
- return dynamic<ConnectContentTabProps>(() => import(`./content/${filePath}/content`), {
- loading: () => (
- <div className="p-4 min-h-[331px]">
- <GenericSkeletonLoader />
- </div>
- ),
- })
- }, [filePath])
-
- return (
- <div ref={ref} {...props} className={cn('border rounded-lg', props.className)}>
- <CopyCallbackContext.Provider value={handleCopy}>
- <ContentFile
- projectKeys={projectKeys}
- filePath={filePath}
- connectionTab={connectionTab}
- selectedFrameworkOrTool={selectedFrameworkOrTool}
- connectionStringPooler={{
- transactionShared: connectionStringsShared.pooler.uri,
- sessionShared: connectionStringsShared.pooler.uri.replace('6543', '5432'),
- transactionDedicated: connectionStringsDedicated?.pooler.uri,
- sessionDedicated: connectionStringsDedicated?.pooler.uri.replace('6543', '5432'),
- ipv4SupportedForDedicatedPooler: !!ipv4Addon,
- direct: connectionStringsShared.direct.uri,
- }}
- onCopy={handleCopy}
- />
- </CopyCallbackContext.Provider>
- </div>
- )
- }
-)
-
-ConnectTabContent.displayName = 'ConnectTabContent'
diff --git a/apps/studio/components/interfaces/Connect/ConnectTabs.tsx b/apps/studio/components/interfaces/Connect/ConnectTabs.tsx
deleted file mode 100644
index 791851c3b8e..00000000000
--- a/apps/studio/components/interfaces/Connect/ConnectTabs.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { FileJson2 } from 'lucide-react'
-import { isValidElement, ReactNode } from 'react'
-import { Tabs_Shadcn_, TabsContent_Shadcn_, TabsList_Shadcn_, TabsTrigger_Shadcn_ } from 'ui'
-
-interface ConnectTabTriggerProps {
- value: string
-}
-interface ConnectTabTriggersProps {
- children: ReactNode[]
-}
-
-interface ConnectFileTabProps {
- children: ReactNode[]
- value?: string
- onValueChange?: (value: string) => void
-}
-
-interface ConnectTabContentProps {
- children: ReactNode
- value: string
-}
-export const ConnectTabs = ({ children, value, onValueChange }: ConnectFileTabProps) => {
- const firstChild = children[0]
-
- const defaultValue = isValidElement(firstChild)
- ? (firstChild.props as any)?.children[0]?.props?.value || ''
- : null
-
- return (
- <Tabs_Shadcn_ defaultValue={defaultValue} value={value} onValueChange={onValueChange}>
- {children}
- </Tabs_Shadcn_>
- )
-}
-
-export const ConnectTabTrigger = ({ value }: ConnectTabTriggerProps) => {
- return (
- <TabsTrigger_Shadcn_
- value={value}
- className="flex items-center gap-1 text-xs px-0 data-[state=active]:bg-transparent py-2.5"
- >
- <FileJson2 size={15} className="text-foreground-muted" />
- {value}
- </TabsTrigger_Shadcn_>
- )
-}
-
-export const ConnectTabTriggers = ({ children }: ConnectTabTriggersProps) => {
- return (
- <TabsList_Shadcn_ className="bg-surface-100 px-5 rounded-lg rounded-b-none gap-5">
- {children}
- </TabsList_Shadcn_>
- )
-}
-
-export const ConnectTabContent = ({ value, children }: ConnectTabContentProps) => {
- return (
- <TabsContent_Shadcn_ value={value} className="p-3 mt-1 max-h-72 overflow-scroll">
- {children}
- </TabsContent_Shadcn_>
- )
-}
diff --git a/apps/studio/components/interfaces/Connect/ConnectionPanel.tsx b/apps/studio/components/interfaces/Connect/ConnectionPanel.tsx
deleted file mode 100644
index acbffe37825..00000000000
--- a/apps/studio/components/interfaces/Connect/ConnectionPanel.tsx
+++ /dev/null
@@ -1,293 +0,0 @@
-import { useParams } from 'common'
-import { ChevronRight, FileCode, X } from 'lucide-react'
-import Link from 'next/link'
-import { PropsWithChildren, ReactNode } from 'react'
-import {
- Badge,
- Button,
- cn,
- Collapsible,
- CollapsibleContent,
- CollapsibleTrigger,
- WarningIcon,
-} from 'ui'
-import { Admonition } from 'ui-patterns/admonition'
-import { CodeBlock, type CodeBlockLang } from 'ui-patterns/CodeBlock'
-
-import { ConnectionParameters } from './ConnectionParameters'
-import { useSupavisorConfigurationQuery } from '@/data/database/supavisor-configuration-query'
-import { IS_PLATFORM } from '@/lib/constants'
-import { useDatabaseSelectorStateSnapshot } from '@/state/database-selector'
-
-interface ConnectionPanelProps {
- type?: 'direct' | 'transaction' | 'session'
- badge?: string
- title: string
- description: string
- contentFooter?: ReactNode
- connectionString: string
- ipv4Status: {
- type: 'error' | 'success'
- title: string
- description?: string | ReactNode
- links?: { text: string; url: string }[]
- }
- notice?: string[]
- parameters?: Array<{
- key: string
- value: string
- description?: string
- }>
- contentType?: 'input' | 'code'
- lang?: CodeBlockLang
- fileTitle?: string
- onCopyCallback: () => void
-}
-
-const IPv4StatusIcon = ({ className, active }: { className?: string; active: boolean }) => {
- return (
- <div className={cn('relative inline-flex', className)}>
- <svg
- xmlns="http://www.w3.org/2000/svg"
- fill="none"
- viewBox="0 0 24 24"
- strokeWidth="1"
- stroke="currentColor"
- className="size-6 stroke-foreground-lighter"
- >
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- d="M12 21a9.004 9.004 0 0 0 8.716-6.747M12 21a9.004 9.004 0 0 1-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 0 1 7.843 4.582M12 3a8.997 8.997 0 0 0-7.843 4.582m15.686 0A11.953 11.953 0 0 1 12 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0 1 21 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0 1 12 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 0 1 3 12c0-1.605.42-3.113 1.157-4.418"
- />
- </svg>
-
- {!active ? (
- <div className="absolute -right-1.5 -top-1.5 bg-destructive rounded-sm w-4 h-4 flex items-center justify-center">
- <X size={10} strokeWidth={4} className="text-white rounded-full" />
- </div>
- ) : (
- <div className="absolute -right-1.5 -top-1.5 bg-brand-500 rounded-sm w-4 h-4 flex items-center justify-center">
- <svg
- width="10"
- height="10"
- viewBox="0 0 10 10"
- fill="none"
- xmlns="http://www.w3.org/2000/svg"
- >
- <path
- d="M8.33325 2.5L3.74992 7.08333L1.66659 5"
- stroke="white"
- strokeWidth="2"
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- </svg>
- </div>
- )}
- </div>
- )
-}
-
-export const CodeBlockFileHeader = ({ title }: { title: string }) => {
- return (
- <div className="flex items-center justify-between px-4 py-1 bg-surface-100/50 border border-b-0 border-surface rounded-t">
- <div className="flex items-center gap-2">
- <FileCode size={12} className="text-foreground-muted" strokeWidth={1.5} />
- <span className="text-xs text-foreground-light">{title}</span>
- </div>
- </div>
- )
-}
-
-export const ConnectionPanel = ({
- type = 'direct',
- badge,
- title,
- description,
- contentFooter,
- connectionString,
- ipv4Status,
- notice,
- parameters = [],
- lang = 'bash',
- fileTitle,
- children,
- onCopyCallback,
-}: PropsWithChildren<ConnectionPanelProps>) => {
- const { ref: projectRef } = useParams()
- const state = useDatabaseSelectorStateSnapshot()
-
- const { data: poolingInfo } = useSupavisorConfigurationQuery({ projectRef })
- const poolingConfiguration = poolingInfo?.find((x) => x.identifier === state.selectedDatabaseId)
- const isSessionMode = poolingConfiguration?.pool_mode === 'session'
-
- const links = ipv4Status.links ?? []
-
- const isTransactionDedicatedPooler = type === 'transaction' && badge === 'Dedicated Pooler'
-
- return (
- <div className="relative text-sm flex flex-col gap-5 lg:grid lg:grid-cols-12 w-full">
- <div className="col-span-4 flex flex-col">
- <div className="flex items-center gap-x-2 mb-2">
- <h1 className="text-sm">{title}</h1>
- {!!badge && !isTransactionDedicatedPooler && <Badge>{badge}</Badge>}
- </div>
- <p className="text-sm text-foreground-light mb-4">{description}</p>
- {contentFooter}
- </div>
- <div className="col-span-8 flex flex-col gap-2">
- {isTransactionDedicatedPooler && (
- <div className="text-xs flex items-center text-foreground-light">
- Using the Dedicated Pooler:
- </div>
- )}
- <div className="flex flex-col -space-y-px">
- {fileTitle && <CodeBlockFileHeader title={fileTitle} />}
- {type === 'transaction' && isSessionMode ? (
- <Admonition
- showIcon={false}
- type="default"
- className="[&>h5]:text-xs [&>div]:text-xs"
- title="Transaction pooler is unavailable as pool mode is set to Session"
- description="If you'd like to use transaction mode, update your pool mode to Transaction for the connection pooler in your project's Database Settings."
- >
- <Button asChild variant="default" className="mt-2">
- <Link
- href={`/project/${projectRef}/database/settings#connection-pooler`}
- className="text-xs text-light hover:text-foreground"
- >
- Database Settings
- </Link>
- </Button>
- </Admonition>
- ) : (
- <>
- <CodeBlock
- wrapperClassName={cn(
- '[&_pre]:rounded-b-none [&_pre]:px-4 [&_pre]:py-3',
- fileTitle && '[&_pre]:rounded-t-none'
- )}
- language={lang}
- value={connectionString}
- className="[&_code]:text-[12px] [&_code]:text-foreground [&_code]:whitespace-normal!"
- hideLineNumbers
- onCopyCallback={onCopyCallback}
- />
- {notice && (
- <div className="border px-4 py-1 w-full justify-start rounded-t-none !last:rounded-b group-data-open:rounded-b-none">
- {notice?.map((text: string) => (
- <p key={text} className="text-xs text-foreground-lighter">
- {text}
- </p>
- ))}
- </div>
- )}
- {parameters.length > 0 && <ConnectionParameters parameters={parameters} />}
- </>
- )}
- </div>
- <div className="flex flex-col -space-y-px w-full">
- {IS_PLATFORM && (
- <div className="border border-muted px-5 flex gap-7 items-center py-3 first:rounded-t last:rounded-b">
- <div className="flex items-center gap-2">
- <IPv4StatusIcon active={ipv4Status.type === 'success'} />
- </div>
- <div className="flex flex-col">
- <span className="text-xs text-foreground">{ipv4Status.title}</span>
- {ipv4Status.description &&
- (typeof ipv4Status.description === 'string' ? (
- <span className="text-xs text-foreground-lighter">
- {ipv4Status.description}
- </span>
- ) : (
- ipv4Status.description
- ))}
- {links.length > 0 && (
- <div className="flex items-center gap-x-2 mt-2">
- {links.map((link) => (
- <Button key={link.text} asChild variant="default" size="tiny">
- <Link href={link.url} className="text-xs text-light hover:text-foreground">
- {link.text}
- </Link>
- </Button>
- ))}
- </div>
- )}
- </div>
- </div>
- )}
-
- {type === 'session' && (
- <div className="border border-muted px-5 flex gap-7 items-center py-3 first:rounded-t last:rounded-b bg-alternative/50">
- <div className="flex w-6 h-6 rounded-sm items-center justify-center gap-2 shrink-0 bg-surface-100">
- <WarningIcon />
- </div>
- <div className="flex flex-col">
- <span className="text-xs text-foreground">Only use on a IPv4 network</span>
- <div className="flex flex-col text-xs text-foreground-lighter">
- <p>Session pooler connections are IPv4 proxied for free.</p>
- <p>Use Direct Connection if connecting via an IPv6 network.</p>
- </div>
- </div>
- </div>
- )}
-
- {IS_PLATFORM && ipv4Status.type === 'error' && (
- <Collapsible className="group -space-y-px">
- <CollapsibleTrigger
- asChild
- className="group/collapse w-full justify-start rounded-t-none !last:rounded-b group-data-open:rounded-b-none border-muted"
- >
- <Button
- variant="default"
- size="tiny"
- className="text-foreground-lighter bg-dash-sidebar!"
- icon={
- <ChevronRight
- className={cn(
- 'group-data-open/collapse:rotate-90 text-foreground-muted transition-transform'
- )}
- />
- }
- >
- Some platforms are IPv4-only:
- </Button>
- </CollapsibleTrigger>
- <CollapsibleContent className="bg-dash-sidebar rounded-b border px-3 py-2">
- <div className="flex flex-col gap-2">
- <p className="text-xs text-foreground-light max-w-xs">
- A few major platforms are IPv4-only and may not work with a Direct Connection:
- </p>
- <div className="flex gap-4">
- <div className="text-foreground text-xs">Vercel</div>
- <div className="text-foreground text-xs">GitHub Actions</div>
- <div className="text-foreground text-xs">Render</div>
- <div className="text-foreground text-xs">Retool</div>
- </div>
- <p className="text-xs text-foreground-lighter max-w-xs">
- If you wish to use a Direct Connection with these, please purchase{' '}
- <Link
- href={`/project/${projectRef}/settings/addons?panel=ipv4`}
- className="text-xs text-light hover:text-foreground"
- >
- IPv4 support
- </Link>
- .
- </p>
- <p className="text-xs text-foreground-lighter max-w-xs">
- You may also use the{' '}
- <span className="text-foreground-light">Session Pooler</span> or{' '}
- <span className="text-foreground-light">Transaction Pooler</span> if you are on
- a IPv4 network.
- </p>
- </div>
- </CollapsibleContent>
- </Collapsible>
- )}
- </div>
- {children}
- </div>
- </div>
- )
-}
diff --git a/apps/studio/components/interfaces/Connect/ConnectionParameters.tsx b/apps/studio/components/interfaces/Connect/ConnectionParameters.tsx
deleted file mode 100644
index 59233d7b4ed..00000000000
--- a/apps/studio/components/interfaces/Connect/ConnectionParameters.tsx
+++ /dev/null
@@ -1,89 +0,0 @@
-import { Check, ChevronRight, Copy } from 'lucide-react'
-import { useState } from 'react'
-import {
- Button,
- cn,
- Collapsible,
- CollapsibleContent,
- CollapsibleTrigger,
- copyToClipboard,
- Separator,
-} from 'ui'
-
-interface Parameter {
- key: string
- value: string
-}
-
-interface ConnectionParametersProps {
- parameters: Parameter[]
-}
-
-export const ConnectionParameters = ({ parameters }: ConnectionParametersProps) => {
- const [isOpen, setIsOpen] = useState(false)
- const [copiedMap, setCopiedMap] = useState<Record<string, boolean>>({})
-
- return (
- <Collapsible open={isOpen} onOpenChange={setIsOpen} className="group -space-y-px">
- <CollapsibleTrigger
- asChild
- className="w-full justify-start rounded-t-none !last:rounded-b group-data-open:rounded-b-none px-3"
- >
- <Button
- variant="default"
- size="tiny"
- className="text-foreground-lighter bg-dash-sidebar!"
- icon={
- <ChevronRight
- className={cn(
- 'text-foreground-muted transition-transform',
- isOpen ? 'rotate-90' : ''
- )}
- />
- }
- >
- View parameters
- </Button>
- </CollapsibleTrigger>
- <CollapsibleContent className="bg-dash-sidebar rounded-b border font-mono text-sm">
- <div className="px-4 py-2">
- {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-xs 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>
- <Separator />
- <div className="text-foreground-muted text-xs px-4 py-1 font-sans">
- For security reasons, your database password is never shown.
- </div>
- </CollapsibleContent>
- </Collapsible>
- )
-}
diff --git a/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx b/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx
deleted file mode 100644
index 97949de5678..00000000000
--- a/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx
+++ /dev/null
@@ -1,672 +0,0 @@
-import { useParams } from 'common'
-import { BookOpen, ChevronDown, ExternalLink } from 'lucide-react'
-import { parseAsString, useQueryState } from 'nuqs'
-import { HTMLAttributes, ReactNode, useEffect, useState } from 'react'
-import {
- Badge,
- Button,
- cn,
- Collapsible,
- CollapsibleContent,
- CollapsibleTrigger,
- DIALOG_PADDING_X,
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
- Separator,
-} from 'ui'
-import { CodeBlock } from 'ui-patterns/CodeBlock'
-import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
-
-import {
- CONNECTION_PARAMETERS,
- connectionStringMethodOptions,
- DATABASE_CONNECTION_TYPES,
- DatabaseConnectionType,
- IPV4_ADDON_TEXT,
- PGBOUNCER_ENABLED_BUT_NO_IPV4_ADDON_TEXT,
- type ConnectionStringMethod,
-} from './Connect.constants'
-import { CodeBlockFileHeader, ConnectionPanel } from './ConnectionPanel'
-import { getConnectionStrings } from './DatabaseSettings.utils'
-import { examples, type Example } from './DirectConnectionExamples'
-import { getAddons } from '@/components/interfaces/Billing/Subscription/Subscription.utils'
-import AlertError from '@/components/ui/AlertError'
-import { DatabaseSelector } from '@/components/ui/DatabaseSelector'
-import { InlineLink } from '@/components/ui/InlineLink'
-import { usePgbouncerConfigQuery } from '@/data/database/pgbouncer-config-query'
-import { useSupavisorConfigurationQuery } from '@/data/database/supavisor-configuration-query'
-import { useReadReplicasQuery } from '@/data/read-replicas/replicas-query'
-import { useProjectAddonsQuery } from '@/data/subscriptions/project-addons-query'
-import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'
-import { DOCS_URL, IS_PLATFORM } from '@/lib/constants'
-import { pluckObjectFields } from '@/lib/helpers'
-import { useTrack } from '@/lib/telemetry/track'
-import { useDatabaseSelectorStateSnapshot } from '@/state/database-selector'
-
-const StepLabel = ({
- number,
- children,
- ...props
-}: { number: number; children: ReactNode } & HTMLAttributes<HTMLDivElement>) => (
- <div {...props} className={cn('flex items-center gap-2', props.className)}>
- <div className="flex font-mono text-xs items-center justify-center min-w-6 w-6 h-6 border border-strong rounded-md bg-surface-100">
- {number}
- </div>
- <span>{children}</span>
- </div>
-)
-
-/**
- * [Joshen] For paid projects - Dedicated pooler is always in transaction mode
- * So session mode connection details are always using the shared pooler (Supavisor)
- */
-export const DatabaseConnectionString = () => {
- const { ref: projectRef } = useParams()
- const state = useDatabaseSelectorStateSnapshot()
- const {
- hasAccess: hasDedicatedPooler,
- isLoading: isLoadingEntitlement,
- isSuccess: isSuccessEntitlement,
- } = useCheckEntitlements('dedicated_pooler')
- const sharedPoolerPreferred = !hasDedicatedPooler
-
- // URL state management
- const [queryType, setQueryType] = useQueryState('type', parseAsString.withDefault('uri'))
- const [querySource, setQuerySource] = useQueryState('source', parseAsString)
- const [queryMethod, setQueryMethod] = useQueryState('method', parseAsString.withDefault('direct'))
-
- const [selectedTab, setSelectedTab] = useState<DatabaseConnectionType>('uri')
- const [selectedMethod, setSelectedMethod] = useState<ConnectionStringMethod>('direct')
-
- // Sync URL state with component state on mount and when URL changes
- useEffect(() => {
- const validTypes = DATABASE_CONNECTION_TYPES.map((t) => t.id)
- if (queryType && validTypes.includes(queryType as DatabaseConnectionType)) {
- setSelectedTab(queryType as DatabaseConnectionType)
- } else if (queryType && !validTypes.includes(queryType as DatabaseConnectionType)) {
- setQueryType('uri')
- setSelectedTab('uri')
- }
-
- const validMethods: ConnectionStringMethod[] = ['direct', 'transaction', 'session']
- if (queryMethod && validMethods.includes(queryMethod as ConnectionStringMethod)) {
- setSelectedMethod(queryMethod as ConnectionStringMethod)
- } else if (queryMethod && !validMethods.includes(queryMethod as ConnectionStringMethod)) {
- setQueryMethod('direct')
- setSelectedMethod('direct')
- }
-
- if (querySource && querySource !== state.selectedDatabaseId) {
- state.setSelectedDatabaseId(querySource)
- } else if (!querySource && state.selectedDatabaseId !== projectRef) {
- state.setSelectedDatabaseId(projectRef)
- }
- }, [queryType, queryMethod, querySource, state])
-
- // Sync component state changes back to URL
- const handleTabChange = (connectionType: DatabaseConnectionType) => {
- setSelectedTab(connectionType)
- setQueryType(connectionType)
- }
-
- const handleMethodChange = (method: ConnectionStringMethod) => {
- setSelectedMethod(method)
- setQueryMethod(method)
- }
-
- const handleDatabaseChange = (databaseId: string) => {
- if (databaseId === projectRef) {
- setQuerySource(null)
- } else {
- setQuerySource(databaseId)
- }
- }
-
- // Sync database selector state changes back to URL
- useEffect(() => {
- if (state.selectedDatabaseId && state.selectedDatabaseId !== querySource) {
- // Only set source in URL if it's not the primary database
- if (state.selectedDatabaseId === projectRef) {
- setQuerySource(null)
- } else {
- setQuerySource(state.selectedDatabaseId)
- }
- }
- }, [state.selectedDatabaseId, querySource, projectRef])
-
- const {
- data: pgbouncerConfig,
- error: pgbouncerError,
- isPending: isLoadingPgbouncerConfig,
- isError: isErrorPgbouncerConfig,
- isSuccess: isSuccessPgBouncerConfig,
- } = usePgbouncerConfigQuery({ projectRef })
- const {
- data: supavisorConfig,
- error: supavisorConfigError,
- isPending: isLoadingSupavisorConfig,
- isError: isErrorSupavisorConfig,
- isSuccess: isSuccessSupavisorConfig,
- } = useSupavisorConfigurationQuery({ projectRef })
-
- const {
- data: databases,
- error: readReplicasError,
- isPending: isLoadingReadReplicas,
- isError: isErrorReadReplicas,
- isSuccess: isSuccessReadReplicas,
- } = useReadReplicasQuery({ projectRef })
-
- const poolerError = sharedPoolerPreferred ? pgbouncerError : supavisorConfigError
- const isLoadingPoolerConfig = !IS_PLATFORM
- ? false
- : sharedPoolerPreferred
- ? isLoadingPgbouncerConfig
- : isLoadingSupavisorConfig
- const isErrorPoolerConfig = !IS_PLATFORM
- ? undefined
- : sharedPoolerPreferred
- ? isErrorPgbouncerConfig
- : isErrorSupavisorConfig
- const isSuccessPoolerConfig = !IS_PLATFORM
- ? true
- : sharedPoolerPreferred
- ? isSuccessPgBouncerConfig
- : isSuccessSupavisorConfig
-
- const error = poolerError || readReplicasError
- const isLoading = isLoadingPoolerConfig || isLoadingReadReplicas || isLoadingEntitlement
- const isError = isErrorPoolerConfig || isErrorReadReplicas
- const isSuccess = isSuccessPoolerConfig && isSuccessReadReplicas && isSuccessEntitlement
-
- const sharedPoolerConfig = supavisorConfig?.find((x) => x.identifier === state.selectedDatabaseId)
- const poolingConfiguration = sharedPoolerPreferred ? sharedPoolerConfig : pgbouncerConfig
-
- const selectedDatabase = (databases ?? []).find(
- (db) => db.identifier === state.selectedDatabaseId
- )
- const isReplicaSelected = selectedDatabase?.identifier !== projectRef
-
- const { data: addons } = useProjectAddonsQuery({ projectRef })
- const { ipv4: ipv4Addon } = getAddons(addons?.selected_addons ?? [])
-
- const track = useTrack()
-
- 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(selectedDatabase || emptyState, DB_FIELDS)
-
- const handleCopy = (
- connectionTypeId: string,
- connectionStringMethod: 'direct' | 'transaction_pooler' | 'session_pooler'
- ) => {
- const connectionInfo = DATABASE_CONNECTION_TYPES.find((type) => type.id === connectionTypeId)
- const connectionType = connectionInfo?.label ?? 'Unknown'
- const lang = connectionInfo?.lang ?? 'Unknown'
- track('connection_string_copied', {
- connectionType,
- lang,
- connectionMethod: connectionStringMethod,
- connectionTab: 'Connection String',
- })
- }
-
- const supavisorConnectionStrings = getConnectionStrings({
- connectionInfo,
- poolingInfo: {
- connectionString: sharedPoolerConfig?.connection_string ?? '',
- db_host: isReplicaSelected ? connectionInfo.db_host : (sharedPoolerConfig?.db_host ?? ''),
- db_name: sharedPoolerConfig?.db_name ?? '',
- db_port: sharedPoolerConfig?.db_port ?? 0,
- db_user: sharedPoolerConfig?.db_user ?? '',
- },
- metadata: { projectRef },
- })
-
- const connectionStrings = getConnectionStrings({
- connectionInfo,
- poolingInfo: {
- connectionString: isReplicaSelected
- ? (poolingConfiguration?.connection_string.replace(
- poolingConfiguration?.db_host,
- connectionInfo.db_host
- ) ?? '')
- : (poolingConfiguration?.connection_string ?? ''),
- db_host: isReplicaSelected ? connectionInfo.db_host : poolingConfiguration?.db_host,
- db_name: poolingConfiguration?.db_name ?? '',
- db_port: poolingConfiguration?.db_port ?? 0,
- db_user: poolingConfiguration?.db_user ?? '',
- },
- metadata: { projectRef },
- })
-
- const lang = DATABASE_CONNECTION_TYPES.find((type) => type.id === selectedTab)?.lang ?? 'bash'
- const contentType =
- DATABASE_CONNECTION_TYPES.find((type) => type.id === selectedTab)?.contentType ?? 'input'
-
- const example: Example | undefined = examples[selectedTab as keyof typeof examples]
-
- const exampleFiles = example?.files
- const exampleInstallCommands = example?.installCommands
- const examplePostInstallCommands = example?.postInstallCommands
- const hasCodeExamples = exampleFiles || exampleInstallCommands
- const fileTitle = DATABASE_CONNECTION_TYPES.find((type) => type.id === selectedTab)?.fileTitle
-
- // [Refactor] See if we can do this in an immutable way, technically not a good practice to do this
- let stepNumber = 0
-
- const ipv4AddOnUrl = {
- text: 'IPv4 add-on',
- url: `/project/${projectRef}/settings/addons?panel=ipv4`,
- }
- const ipv4SettingsUrl = {
- text: 'IPv4 settings',
- url: `/project/${projectRef}/settings/addons?panel=ipv4`,
- }
- const poolerSettingsUrl = {
- text: 'Pooler settings',
- url: `/project/${projectRef}/database/settings#connection-pooling`,
- }
- const buttonLinks = !ipv4Addon
- ? [ipv4AddOnUrl, ...(sharedPoolerPreferred ? [poolerSettingsUrl] : [])]
- : [ipv4SettingsUrl, ...(sharedPoolerPreferred ? [poolerSettingsUrl] : [])]
- const poolerBadge = sharedPoolerPreferred ? 'Shared Pooler' : 'Dedicated Pooler'
-
- return (
- <div className="flex flex-col">
- <div className={cn('w-full flex flex-col items-start gap-2 lg:gap-3', DIALOG_PADDING_X)}>
- <div className="flex w-full flex-col md:flex-row items-stretch md:items-center gap-2 md:gap-3">
- <div className="flex">
- <span className="w-1/2 md:w-auto flex items-center text-foreground-lighter px-3 rounded-lg rounded-r-none text-xs border border-button border-r-0">
- Type
- </span>
- <Select value={selectedTab} onValueChange={handleTabChange}>
- <SelectTrigger size="small" className="w-full md:w-auto rounded-l-none">
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- {DATABASE_CONNECTION_TYPES.map((type) => (
- <SelectItem key={type.id} value={type.id}>
- {type.label}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- </div>
- <DatabaseSelector
- align="start"
- buttonProps={{
- size: 'small',
- className: 'w-full pr-2.5 [&_svg]:h-4',
- }}
- className="w-full md:w-auto [&>span]:w-1/2 [&>span]:md:w-auto"
- onSelectId={handleDatabaseChange}
- />
- <div className="flex">
- <span className="w-1/2 md:w-auto flex items-center text-foreground-lighter px-3 rounded-lg rounded-r-none text-xs border border-button border-r-0">
- Method
- </span>
- <Select value={selectedMethod} onValueChange={handleMethodChange}>
- <SelectTrigger size="small" className="w-full md:w-auto rounded-l-none">
- <SelectValue size="tiny">
- {connectionStringMethodOptions[selectedMethod].label}
- </SelectValue>
- </SelectTrigger>
- <SelectContent className="max-w-sm">
- {Object.keys(connectionStringMethodOptions).map((method) => (
- <ConnectionStringMethodSelectItem
- key={method}
- method={method as ConnectionStringMethod}
- poolerBadge={method === 'transaction' ? poolerBadge : undefined}
- />
- ))}
- </SelectContent>
- </Select>
- </div>
- </div>
- <p className="text-xs inline-flex items-center gap-1 text-foreground-lighter">
- <BookOpen size={12} strokeWidth={1.5} className="-mb-px" /> Learn how to connect to your
- Postgres databases.
- <InlineLink
- title="Read docs"
- className="flex items-center gap-x-1"
- href={`${DOCS_URL}/guides/database/connecting-to-postgres`}
- >
- Read docs <ExternalLink size={12} strokeWidth={1.5} />
- </InlineLink>
- </p>
- </div>
-
- {isLoading && (
- <div className="p-7">
- <ShimmeringLoader className="h-8 w-full" />
- </div>
- )}
-
- {isError && (
- <div className="p-7">
- <AlertError error={error} subject="Failed to retrieve database settings" />
- </div>
- )}
-
- {isSuccess && (
- <div className="flex flex-col divide-y divide-border">
- {/* // handle non terminal examples */}
- {hasCodeExamples && (
- <div className="flex flex-col w-full">
- <div className="grid lg:grid-cols-3 gap-4 lg:gap-5 py-8 px-4 md:px-7">
- <StepLabel number={++stepNumber} className="items-start">
- Install the following
- </StepLabel>
- {exampleInstallCommands?.map((cmd) => (
- <CodeBlock
- key={`example-install-command-${cmd}`}
- className="[&_code]:text-[12px] [&_code]:text-foreground"
- wrapperClassName="lg:col-span-2"
- value={cmd}
- hideLineNumbers
- language="bash"
- >
- {cmd}
- </CodeBlock>
- ))}
- </div>
- {exampleFiles && exampleFiles?.length > 0 && (
- <div className="grid lg:grid-cols-3 gap-4 lg:gap-5 border-t py-8 px-4 md:px-7">
- <StepLabel number={++stepNumber} className="items-start">
- Add file to project
- </StepLabel>
- {exampleFiles?.map((file) => (
- <div key={`example-files-${file.name}`} className="lg:col-span-2">
- <CodeBlockFileHeader title={file.name} />
- <CodeBlock
- wrapperClassName="[&_pre]:max-h-40 [&_pre]:px-4 [&_pre]:py-3 [&_pre]:rounded-t-none"
- value={file.content}
- hideLineNumbers
- language={lang}
- className="[&_code]:text-[12px] [&_code]:text-foreground"
- />
- </div>
- ))}
- </div>
- )}
- </div>
- )}
-
- <div>
- {hasCodeExamples && (
- <div className="px-4 md:px-7 pt-8">
- <StepLabel number={++stepNumber}>Connect to your database</StepLabel>
- </div>
- )}
- <div className="px-4 md:px-7 py-8">
- {selectedMethod === 'direct' && (
- <ConnectionPanel
- type="direct"
- title={connectionStringMethodOptions.direct.label}
- contentType={contentType}
- lang={lang}
- fileTitle={fileTitle}
- description={connectionStringMethodOptions.direct.description}
- connectionString={connectionStrings['direct'][selectedTab]}
- ipv4Status={{
- type: !ipv4Addon ? 'error' : 'success',
- title: !ipv4Addon ? 'Not IPv4 compatible' : 'IPv4 compatible',
- description:
- !sharedPoolerPreferred && !ipv4Addon
- ? PGBOUNCER_ENABLED_BUT_NO_IPV4_ADDON_TEXT
- : sharedPoolerPreferred
- ? 'Use Session Pooler if on a IPv4 network or purchase IPv4 add-on'
- : IPV4_ADDON_TEXT,
- links: buttonLinks,
- }}
- parameters={[
- { ...CONNECTION_PARAMETERS.host, value: connectionInfo.db_host },
- { ...CONNECTION_PARAMETERS.port, value: connectionInfo.db_port },
- { ...CONNECTION_PARAMETERS.database, value: connectionInfo.db_name },
- { ...CONNECTION_PARAMETERS.user, value: connectionInfo.db_user },
- ]}
- onCopyCallback={() => handleCopy(selectedTab, 'direct')}
- />
- )}
-
- {selectedMethod === 'transaction' && IS_PLATFORM && (
- <ConnectionPanel
- type="transaction"
- title={connectionStringMethodOptions.transaction.label}
- contentType={contentType}
- lang={lang}
- badge={poolerBadge}
- fileTitle={fileTitle}
- description={connectionStringMethodOptions.transaction.description}
- connectionString={connectionStrings['pooler'][selectedTab]}
- ipv4Status={{
- type: !sharedPoolerPreferred && !ipv4Addon ? 'error' : 'success',
- title:
- !sharedPoolerPreferred && !ipv4Addon
- ? 'Not IPv4 compatible'
- : 'IPv4 compatible',
- description:
- !sharedPoolerPreferred && !ipv4Addon
- ? PGBOUNCER_ENABLED_BUT_NO_IPV4_ADDON_TEXT
- : sharedPoolerPreferred
- ? 'Transaction pooler connections are IPv4 proxied for free.'
- : IPV4_ADDON_TEXT,
- links: !sharedPoolerPreferred ? buttonLinks : undefined,
- }}
- notice={['Does not support PREPARE statements']}
- parameters={[
- {
- ...CONNECTION_PARAMETERS.host,
- value: isReplicaSelected
- ? connectionInfo.db_host
- : (poolingConfiguration?.db_host ?? ''),
- },
- {
- ...CONNECTION_PARAMETERS.port,
- value: poolingConfiguration?.db_port.toString() ?? '6543',
- },
- {
- ...CONNECTION_PARAMETERS.database,
- value: poolingConfiguration?.db_name ?? '',
- },
- { ...CONNECTION_PARAMETERS.user, value: poolingConfiguration?.db_user ?? '' },
- { ...CONNECTION_PARAMETERS.pool_mode, value: 'transaction' },
- ]}
- onCopyCallback={() => handleCopy(selectedTab, 'transaction_pooler')}
- >
- {!sharedPoolerPreferred && !ipv4Addon && (
- <>
- <Separator className="w-full" />
- <Collapsible className="group">
- <CollapsibleTrigger
- asChild
- className="w-full justify-start !last:rounded-b group-data-open:rounded-b-none px-3"
- >
- <Button
- variant="default"
- size="large"
- iconRight={
- <ChevronDown className="transition group-data-open:rotate-180" />
- }
- className="text-foreground bg-dash-sidebar! justify-between"
- >
- <div className="text-xs flex items-center gap-x-2 py-2 px-1">
- <span>Using the Shared Pooler</span>
- <Badge variant="success">IPv4 compatible</Badge>
- </div>
- </Button>
- </CollapsibleTrigger>
- <CollapsibleContent className="bg-dash-sidebar rounded-b border text-xs">
- <CodeBlock
- wrapperClassName={cn(
- '[&_pre]:border-x-0 [&_pre]:border-t-0 [&_pre]:px-4 [&_pre]:py-3',
- '[&_pre]:rounded-t-none'
- )}
- language={lang}
- value={supavisorConnectionStrings['pooler'][selectedTab]}
- className="[&_code]:text-[12px] [&_code]:text-foreground"
- hideLineNumbers
- onCopyCallback={() => handleCopy(selectedTab, 'transaction_pooler')}
- />
- <p className="px-3 py-2 text-foreground-light">
- Only recommended when your network does not support IPv6. Added latency
- compared to dedicated pooler.
- </p>
- </CollapsibleContent>
- </Collapsible>
- </>
- )}
- </ConnectionPanel>
- )}
-
- {selectedMethod === 'session' && IS_PLATFORM && (
- <ConnectionPanel
- type="session"
- title={connectionStringMethodOptions.session.label}
- contentType={contentType}
- lang={lang}
- badge="Shared Pooler"
- fileTitle={fileTitle}
- description={connectionStringMethodOptions.session.description}
- connectionString={supavisorConnectionStrings['pooler'][selectedTab].replace(
- '6543',
- '5432'
- )}
- ipv4Status={{
- type: 'success',
- title: 'IPv4 compatible',
- description: 'Session pooler connections are IPv4 proxied for free',
- links: undefined,
- }}
- parameters={[
- { ...CONNECTION_PARAMETERS.host, value: sharedPoolerConfig?.db_host ?? '' },
- { ...CONNECTION_PARAMETERS.port, value: '5432' },
- {
- ...CONNECTION_PARAMETERS.database,
- value: sharedPoolerConfig?.db_name ?? '',
- },
- { ...CONNECTION_PARAMETERS.user, value: sharedPoolerConfig?.db_user ?? '' },
- { ...CONNECTION_PARAMETERS.pool_mode, value: 'session' },
- ]}
- onCopyCallback={() => handleCopy(selectedTab, 'session_pooler')}
- />
- )}
- </div>
- </div>
-
- {examplePostInstallCommands && (
- <div className="grid lg:grid-cols-3 gap-4 lg:gap-5 w-full px-4 md:px-7 py-8">
- <StepLabel number={++stepNumber} className="items-start">
- Add the configuration package to read the settings
- </StepLabel>
- {examplePostInstallCommands?.map((cmd) => (
- <CodeBlock
- key={`example-post-install-commands-${cmd}`}
- className="text-sm"
- wrapperClassName="lg:col-span-2"
- value={cmd}
- hideLineNumbers
- language="bash"
- >
- {cmd}
- </CodeBlock>
- ))}
- </div>
- )}
- </div>
- )}
-
- {selectedTab === 'python' && (
- <>
- <Separator />
- <Collapsible className="px-8 py-5">
- <CollapsibleTrigger className="group [&[data-state=open]>div>svg]:-rotate-180!">
- <div className="flex items-center gap-x-2 w-full">
- <p className="text-xs text-foreground-light group-hover:text-foreground transition">
- Connecting to SQL Alchemy
- </p>
- <ChevronDown
- className="transition-transform duration-200"
- strokeWidth={1.5}
- size={14}
- />
- </div>
- </CollapsibleTrigger>
- <CollapsibleContent className="my-2">
- <div className="text-foreground-light text-xs grid gap-2">
- <p>
- Please use <code>postgresql://</code> instead of <code>postgres://</code> as your
- dialect when connecting via SQLAlchemy.
- </p>
- <p>
- Example:
- <code>create_engine("postgresql+psycopg2://...")</code>
- </p>
- <p className="text-sm font-mono tracking-tight text-foreground-lighter"></p>
- </div>
- </CollapsibleContent>
- </Collapsible>
- </>
- )}
-
- <Separator />
- <div className="px-8 pt-5 flex flex-col gap-y-1">
- <p className="text-sm">Reset your database password</p>
- <p className="text-sm text-foreground-lighter">
- You may reset your database password in your project's{' '}
- <InlineLink
- href={`/project/${projectRef}/database/settings`}
- className="text-foreground-lighter hover:text-foreground"
- >
- Database Settings
- </InlineLink>
- </p>
- </div>
- </div>
- )
-}
-
-const ConnectionStringMethodSelectItem = ({
- method,
- poolerBadge,
-}: {
- method: ConnectionStringMethod
- poolerBadge?: string
-}) => {
- const badges: ReactNode[] = []
-
- if (method !== 'direct') {
- badges.push(
- <Badge key="direct" className="flex gap-x-1">
- Shared Pooler
- </Badge>
- )
- }
- if (poolerBadge === 'Dedicated Pooler') {
- badges.push(
- <Badge key="dedicated" className="flex gap-x-1">
- {poolerBadge}
- </Badge>
- )
- }
-
- return (
- <SelectItem value={method} className="[&>span:first-child]:top-3.5">
- <div className="flex flex-col w-full py-1">
- <div className="flex gap-x-2 items-center">
- {connectionStringMethodOptions[method].label}
- </div>
- <div className="text-foreground-lighter text-xs">
- {connectionStringMethodOptions[method].description}
- </div>
- <div className="flex items-center gap-0.5 flex-wrap mt-1.5">
- {badges.map((badge) => badge)}
- </div>
- </div>
- </SelectItem>
- )
-}
diff --git a/apps/studio/components/interfaces/Connect/DirectConnectionExamples.tsx b/apps/studio/components/interfaces/Connect/DirectConnectionExamples.tsx
deleted file mode 100644
index fb3b6c06c6c..00000000000
--- a/apps/studio/components/interfaces/Connect/DirectConnectionExamples.tsx
+++ /dev/null
@@ -1,151 +0,0 @@
-export type Example = {
- installCommands?: string[]
- postInstallCommands?: string[]
- files?: {
- name: string
- content: string
- }[]
-}
-
-export 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}")`,
- },
- ],
- },
-}
diff --git a/apps/studio/components/interfaces/Connect/McpTabContent.tsx b/apps/studio/components/interfaces/Connect/McpTabContent.tsx
deleted file mode 100644
index 7f6bf6cd97d..00000000000
--- a/apps/studio/components/interfaces/Connect/McpTabContent.tsx
+++ /dev/null
@@ -1,76 +0,0 @@
-import { IS_PLATFORM, useParams } from 'common'
-import { useTheme } from 'next-themes'
-import { useMemo, useState } from 'react'
-import { createMcpCopyHandler, McpConfigPanel, type McpClient } from 'ui-patterns/McpUrlBuilder'
-import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
-
-import type { projectKeys } from './Connect.types'
-import Panel from '@/components/ui/Panel'
-import { useTrack } from '@/lib/telemetry/track'
-
-export const McpTabContent = ({ projectKeys }: { projectKeys: projectKeys }) => {
- const { ref: projectRef } = useParams()
-
- return (
- <Panel className="bg-inherit border-none shadow-none">
- {projectRef ? (
- <McpTabContentInnerLoaded projectRef={projectRef} projectKeys={projectKeys} />
- ) : (
- <McpTabContentInnerLoading />
- )}
- </Panel>
- )
-}
-
-const McpTabContentInnerLoading = () => {
- return (
- <div className="flex flex-col gap-2">
- <ShimmeringLoader className="w-3/4" />
- <ShimmeringLoader className="w-1/2" />
- </div>
- )
-}
-
-const McpTabContentInnerLoaded = ({
- projectRef,
- projectKeys,
-}: {
- projectRef: string
- projectKeys: projectKeys
-}) => {
- const { resolvedTheme } = useTheme()
- const track = useTrack()
- const [selectedClient, setSelectedClient] = useState<McpClient | null>(null)
-
- const handleCopy = useMemo(
- () =>
- createMcpCopyHandler({
- selectedClient,
- source: 'studio',
- onTrack: (event) => track(event.action, event.properties, event.groups),
- projectRef,
- }),
- [selectedClient, track, projectRef]
- )
-
- const handleInstall = () => {
- if (selectedClient?.label) {
- track('mcp_install_button_clicked', {
- client: selectedClient.label,
- source: 'studio',
- })
- }
- }
-
- return (
- <McpConfigPanel
- projectRef={projectRef}
- theme={resolvedTheme as 'light' | 'dark'}
- isPlatform={IS_PLATFORM}
- apiUrl={projectKeys.apiUrl ?? undefined}
- onCopyCallback={handleCopy}
- onInstallCallback={handleInstall}
- onClientSelect={setSelectedClient}
- />
- )
-}
diff --git a/apps/studio/components/interfaces/Connect/content/androidkotlin/supabasekt/content.tsx b/apps/studio/components/interfaces/Connect/content/androidkotlin/supabasekt/content.tsx
deleted file mode 100644
index 66caa833bff..00000000000
--- a/apps/studio/components/interfaces/Connect/content/androidkotlin/supabasekt/content.tsx
+++ /dev/null
@@ -1,83 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value="MainActivity.kt" />
- <ConnectTabTrigger value="TodoItem.kt" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value="TodoItem.kt">
- <SimpleCodeBlock className="kotlin" parentClassName="min-h-72">
- {`
-@Serializable
-data class TodoItem(val id: Int, val name: String)
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="MainActivity.kt">
- <SimpleCodeBlock className="kotlin" parentClassName="min-h-72">
- {`
-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),
- )
- }
- }
-}
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/astro/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/astro/supabasejs/content.tsx
deleted file mode 100644
index cf8c7c9dcc6..00000000000
--- a/apps/studio/components/interfaces/Connect/content/astro/supabasejs/content.tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value=".env.local" />
- <ConnectTabTrigger value="src/db/supabase.js" />
- <ConnectTabTrigger value="src/pages/index.astro" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value=".env.local">
- <SimpleCodeBlock className="bash" parentClassName="min-h-72">
- {`
-SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
-SUPABASE_KEY=${projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'}
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="src/db/supabase.js">
- <SimpleCodeBlock className="js" parentClassName="min-h-72">
- {`
-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);
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="src/pages/index.astro">
- <SimpleCodeBlock className="html" parentClassName="min-h-72">
- {`
----
-import { supabase } from '../db/supabase';
-
-const { data, error } = await supabase.from("todos").select('*');
----
-
-{
- (
- <ul>
- {data.map((entry) => (
- <li>{entry.name}</li>
- ))}
- </ul>
- )
-}
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/drizzle/content.tsx b/apps/studio/components/interfaces/Connect/content/drizzle/content.tsx
deleted file mode 100644
index 2ef670083a6..00000000000
--- a/apps/studio/components/interfaces/Connect/content/drizzle/content.tsx
+++ /dev/null
@@ -1,77 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ connectionStringPooler }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value=".env" />
- <ConnectTabTrigger value="drizzle/schema.tsx" />
- <ConnectTabTrigger value="index.tsx" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value=".env">
- <SimpleCodeBlock className="bash" parentClassName="min-h-72">
- {connectionStringPooler.ipv4SupportedForDedicatedPooler &&
- connectionStringPooler.transactionDedicated
- ? `
-DATABASE_URL="${connectionStringPooler.transactionDedicated}"
- `
- : connectionStringPooler.transactionDedicated &&
- !connectionStringPooler.ipv4SupportedForDedicatedPooler
- ? `
-# Use Shared connection pooler (supports both IPv4/IPv6)
-DATABASE_URL="${connectionStringPooler.transactionShared}"
-
-# If your network supports IPv6 or you purchased IPv4 addon, use dedicated pooler
-# DATABASE_URL="${connectionStringPooler.transactionDedicated}"
- `
- : `
-DATABASE_URL="${connectionStringPooler.transactionShared}"
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="drizzle/schema.tsx">
- <SimpleCodeBlock className="tsx" parentClassName="min-h-72">
- {`
-import { pgTable, serial, text, varchar } from "drizzle-orm/pg-core";
-
-export const users = pgTable('users', {
- id: serial('id').primaryKey(),
- fullName: text('full_name'),
- phone: varchar('phone', { length: 256 }),
-});
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="index.tsx">
- <SimpleCodeBlock className="tsx" parentClassName="min-h-72">
- {`
-import { drizzle } from 'drizzle-orm/postgres-js'
-import postgres from 'postgres'
-import { users } from './schema'
-
-const connectionString = process.env.DATABASE_URL
-
-// Disable prefetch as it is not supported for "Transaction" pool mode
-const client = postgres(connectionString, { prepare: false })
-const db = drizzle(client);
-
-const allUsers = await db.select().from(users);
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/exporeactnative/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/exporeactnative/supabasejs/content.tsx
deleted file mode 100644
index 04a5806333d..00000000000
--- a/apps/studio/components/interfaces/Connect/content/exporeactnative/supabasejs/content.tsx
+++ /dev/null
@@ -1,102 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value=".env.local" />
- <ConnectTabTrigger value="utils/supabase.ts" />
- <ConnectTabTrigger value="App.tsx" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value=".env.local">
- <SimpleCodeBlock className="bash" parentClassName="min-h-72">
- {`
-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>'}
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="utils/supabase.ts">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-import 'react-native-url-polyfill/auto'
-import AsyncStorage from '@react-native-async-storage/async-storage'
-import { createClient, processLock } 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,
- lock: processLock,
- },
- })
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="App.tsx">
- <SimpleCodeBlock className="tsx" parentClassName="min-h-72">
- {`
-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.title}</Text>}
- />
- </View>
- );
-};
-
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/flask/supabasepy/content.tsx b/apps/studio/components/interfaces/Connect/content/flask/supabasepy/content.tsx
deleted file mode 100644
index 08ff15511e1..00000000000
--- a/apps/studio/components/interfaces/Connect/content/flask/supabasepy/content.tsx
+++ /dev/null
@@ -1,66 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value=".env" />
- <ConnectTabTrigger value="app.py" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value=".env">
- <SimpleCodeBlock className="bash" parentClassName="min-h-72">
- {`
-SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
-SUPABASE_KEY=${projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'}
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="app.py">
- <SimpleCodeBlock className="python" parentClassName="min-h-72">
- {`
-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)
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/flutter/supabaseflutter/content.tsx b/apps/studio/components/interfaces/Connect/content/flutter/supabaseflutter/content.tsx
deleted file mode 100644
index 26356a92a19..00000000000
--- a/apps/studio/components/interfaces/Connect/content/flutter/supabaseflutter/content.tsx
+++ /dev/null
@@ -1,93 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value="lib/main.dart" />
- <ConnectTabTrigger value="lib/main.dart (app)" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value="lib/main.dart">
- <SimpleCodeBlock className="dart" parentClassName="min-h-72">
- {`
-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());
-}
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="lib/main.dart (app)">
- <SimpleCodeBlock className="dart" parentClassName="min-h-72">
- {`
-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']),
- );
- }),
- );
- },
- ),
- );
- }
-}
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/ionicangular/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/ionicangular/supabasejs/content.tsx
deleted file mode 100644
index 5470df4a99b..00000000000
--- a/apps/studio/components/interfaces/Connect/content/ionicangular/supabasejs/content.tsx
+++ /dev/null
@@ -1,145 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value="environments/environment.ts" />
- <ConnectTabTrigger value="src/app/supabase.service.ts" />
- <ConnectTabTrigger value="src/app/app.component.ts" />
- <ConnectTabTrigger value="src/app/app.component.html" />
- <ConnectTabTrigger value="src/app/app.module.ts" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value="environments/environment.ts">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-export const environment = {
- supabaseUrl: '${projectKeys.apiUrl ?? 'your-project-url'}',
- supabaseKey: '${projectKeys.publishableKey ?? '<prefer publishable key instead of anon key for mobile apps>'}',
-};
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="src/app/supabase.service.ts">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-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('*');
- }
-}
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="src/app/app.component.ts">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-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;
- }
- }
-}
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="src/app/app.component.html">
- <SimpleCodeBlock className="html" parentClassName="min-h-72">
- {`
-<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.title }}</ion-label>
- </ion-item>
-</ion-list>
-</ion-content>
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="src/app/app.module.ts">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-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 {}
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/ionicreact/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/ionicreact/supabasejs/content.tsx
deleted file mode 100644
index 2121f100ac6..00000000000
--- a/apps/studio/components/interfaces/Connect/content/ionicreact/supabasejs/content.tsx
+++ /dev/null
@@ -1,115 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value=".env" />
- <ConnectTabTrigger value="src/supabaseClient.tsx" />
- <ConnectTabTrigger value="src/App.tsx" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value=".env">
- <SimpleCodeBlock className="bash" parentClassName="min-h-72">
- {`
-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>'}
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="src/supabaseClient.tsx">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-import { createClient } from '@supabase/supabase-js'
-
-const supabaseUrl = process.env.REACT_APP_SUPABASE_URL
-const supabaseKey = process.env.REACT_APP_SUPABASE_KEY
-
-export const supabase = createClient(supabaseUrl, supabaseAnonKey)
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="src/App.tsx">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-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.title}</IonItem>
- ))}
- </IonList>
- </IonContent>
- </>
- </IonApp>
- );
-}
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/nextjs/app/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/nextjs/app/supabasejs/content.tsx
deleted file mode 100644
index 5a9bb68f2d4..00000000000
--- a/apps/studio/components/interfaces/Connect/content/nextjs/app/supabasejs/content.tsx
+++ /dev/null
@@ -1,159 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value=".env.local" />
- <ConnectTabTrigger value="page.tsx" />
- <ConnectTabTrigger value="utils/supabase/server.ts" />
- <ConnectTabTrigger value="utils/supabase/client.ts" />
- <ConnectTabTrigger value="utils/supabase/middleware.ts" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value=".env.local">
- <SimpleCodeBlock className="bash" parentClassName="min-h-72">
- {[
- '',
- `NEXT_PUBLIC_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
- projectKeys?.publishableKey
- ? `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=${projectKeys.publishableKey}`
- : `NEXT_PUBLIC_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
- '',
- ].join('\n')}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="page.tsx">
- <SimpleCodeBlock className="tsx" parentClassName="min-h-72">
- {`
-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>{todo}</li>
- ))}
- </ul>
- )
-}
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="utils/supabase/server.ts">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-import { createServerClient, type CookieOptions } 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_KEY' : 'NEXT_PUBLIC_SUPABASE_ANON_KEY'};
-
-export const createClient = (cookieStore: 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.
- }
- },
- },
- },
- );
-};
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- <ConnectTabContent value="utils/supabase/client.ts">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-import { createBrowserClient } from "@supabase/ssr";
-
-const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
-const supabaseKey = process.env.${projectKeys?.publishableKey ? 'NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY' : 'NEXT_PUBLIC_SUPABASE_ANON_KEY'};
-
-export const createClient = () =>
- createBrowserClient(
- supabaseUrl!,
- supabaseKey!,
- );
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="utils/supabase/middleware.ts">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-import { createServerClient, type CookieOptions } 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_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
-};
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-// [Joshen] Used as a dynamic import
-// eslint-disable-next-line no-restricted-exports
-export default ContentFile
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
deleted file mode 100644
index 2fdddb466aa..00000000000
--- a/apps/studio/components/interfaces/Connect/content/nextjs/pages/supabasejs/content.tsx
+++ /dev/null
@@ -1,84 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value=".env.local" />
- <ConnectTabTrigger value="utils/supabase.ts" />
- <ConnectTabTrigger value="_app.tsx" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value=".env.local">
- <SimpleCodeBlock className="bash" parentClassName="min-h-72">
- {[
- '',
- `NEXT_PUBLIC_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
- projectKeys?.publishableKey
- ? `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=${projectKeys.publishableKey}`
- : `NEXT_PUBLIC_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
- '',
- ].join('\n')}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="utils/supabase.ts">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-import { createClient } from "@supabase/supabase-js";
-
-const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
-const supabaseKey = process.env.${projectKeys?.publishableKey ? 'NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY' : 'NEXT_PUBLIC_SUPABASE_ANON_KEY'};
-
-export const supabase = createClient(supabaseUrl, supabaseKey);
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="_app.tsx">
- <SimpleCodeBlock className="tsx" parentClassName="min-h-72">
- {`
-import { useState, useEffect } from 'react'
-import { supabase } from '../utils/supabase'
-
-function Page() {
- const [todos, setTodos] = useState([])
-
- useEffect(() => {
- async function getTodos() {
- const { data: todos } = await supabase.from('todos').select()
-
- if (todos.length > 1) {
- setTodos(todos)
- }
- }
-
- getTodos()
- }, [])
-
- return (
- <div>
- {todos.map((todo) => (
- <li key={todo}>{todo}</li>
- ))}
- </div>
- )
-}
-export default Page
-
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/nuxt/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/nuxt/supabasejs/content.tsx
deleted file mode 100644
index 1c9cfe2633a..00000000000
--- a/apps/studio/components/interfaces/Connect/content/nuxt/supabasejs/content.tsx
+++ /dev/null
@@ -1,72 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value=".env.local" />
- <ConnectTabTrigger value="utils/supabase.ts" />
- <ConnectTabTrigger value="src/App.vue" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value=".env.local">
- <SimpleCodeBlock className="bash" parentClassName="min-h-72">
- {`
-SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
-SUPABASE_KEY=${projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'}
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="utils/supabase.ts">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-import { createClient } from "@supabase/supabase-js";
-
-const supabaseUrl = process.env.SUPABASE_URL;
-const supabaseKey = process.env.SUPABASE_KEY;
-
-export const supabase = createClient(supabaseUrl, supabaseKey);
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="src/App.vue">
- <SimpleCodeBlock className="jsx" parentClassName="min-h-72">
- {`
-<script setup>
- 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>
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/prisma/content.tsx b/apps/studio/components/interfaces/Connect/content/prisma/content.tsx
deleted file mode 100644
index 89b1552a607..00000000000
--- a/apps/studio/components/interfaces/Connect/content/prisma/content.tsx
+++ /dev/null
@@ -1,73 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-import { IS_PLATFORM } from '@/lib/constants'
-
-const ContentFile = ({ connectionStringPooler }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value=".env.local" />
- <ConnectTabTrigger value="prisma/schema.prisma" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value=".env.local">
- <SimpleCodeBlock className="bash" parentClassName="min-h-72">
- {connectionStringPooler.ipv4SupportedForDedicatedPooler &&
- connectionStringPooler.transactionDedicated
- ? `
-# Connect to Supabase via connection pooling.
-DATABASE_URL="${connectionStringPooler.transactionDedicated}?pgbouncer=true"
-
-# Direct connection to the database. Used for migrations.
-DIRECT_URL="${connectionStringPooler.sessionDedicated}"
- `
- : connectionStringPooler.transactionDedicated &&
- !connectionStringPooler.ipv4SupportedForDedicatedPooler
- ? `
-# Connect to Supabase via Shared Connection Pooler
-DATABASE_URL="${connectionStringPooler.transactionShared}?pgbouncer=true"
-
-# Direct connection to the database through Shared Pooler (supports IPv4/IPv6). Used for migrations.
-DIRECT_URL="${connectionStringPooler.sessionShared}"
-
-# If your network supports IPv6 or you purchased IPv4 addon, use dedicated pooler
-# DATABASE_URL="${connectionStringPooler.transactionDedicated}?pgbouncer=true"
-# DIRECT_URL="${connectionStringPooler.sessionDedicated}"
- `
- : `
-# Connect to Supabase ${IS_PLATFORM ? 'via connection pooling' : ''}
-DATABASE_URL="${IS_PLATFORM ? `${connectionStringPooler.transactionShared}?pgbouncer=true` : connectionStringPooler.direct}"
-
-# Direct connection to the database. Used for migrations
-DIRECT_URL="${IS_PLATFORM ? connectionStringPooler.sessionShared : connectionStringPooler.direct}"
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="prisma/schema.prisma">
- <SimpleCodeBlock className="bash" parentClassName="min-h-72">
- {`
-generator client {
- provider = "prisma-client-js"
-}
-
-datasource db {
- provider = "postgresql"
- url = env("DATABASE_URL")
- directUrl = env("DIRECT_URL")
-}
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/react/create-react-app/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/react/create-react-app/supabasejs/content.tsx
deleted file mode 100644
index c2c865eaadc..00000000000
--- a/apps/studio/components/interfaces/Connect/content/react/create-react-app/supabasejs/content.tsx
+++ /dev/null
@@ -1,83 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value=".env.local" />
- <ConnectTabTrigger value="utils/supabase.ts" />
- <ConnectTabTrigger value="App.tsx" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value=".env.local">
- <SimpleCodeBlock className="bash" parentClassName="min-h-72">
- {[
- '',
- `REACT_APP_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
- projectKeys?.publishableKey
- ? `REACT_APP_SUPABASE_PUBLISHABLE_KEY=${projectKeys.publishableKey}`
- : `REACT_APP_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
- '',
- ].join('\n')}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="utils/supabase.ts">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-import { createClient } from "@supabase/supabase-js";
-
-const supabaseUrl = process.env.REACT_APP_SUPABASE_URL;
-const supabaseKey = process.env.${projectKeys.publishableKey ? 'REACT_APP_SUPABASE_PUBLISHABLE_KEY' : 'REACT_APP_SUPABASE_ANON_KEY'};
-
-export const supabase = createClient(supabaseUrl, supabaseKey);
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="App.tsx">
- <SimpleCodeBlock className="tsx" parentClassName="min-h-72">
- {`
-import { useState, useEffect } from 'react'
-import { supabase } from '../utils/supabase'
-
-function Page() {
- const [todos, setTodos] = useState([])
-
- useEffect(() => {
- function getTodos() {
- const { data: todos } = await supabase.from('todos').select()
-
- if (todos.length > 1) {
- setTodos(todos)
- }
- }
-
- getTodos()
- }, [])
-
- return (
- <div>
- {todos.map((todo) => (
- <li key={todo}>{todo}</li>
- ))}
- </div>
- )
-}
-export default Page
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/react/vite/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/react/vite/supabasejs/content.tsx
deleted file mode 100644
index df57ef0ab37..00000000000
--- a/apps/studio/components/interfaces/Connect/content/react/vite/supabasejs/content.tsx
+++ /dev/null
@@ -1,85 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value=".env" />
- <ConnectTabTrigger value="utils/supabase.ts" />
- <ConnectTabTrigger value="App.tsx" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value=".env">
- <SimpleCodeBlock className="bash" parentClassName="min-h-72">
- {[
- '',
- `VITE_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
- projectKeys?.publishableKey
- ? `VITE_SUPABASE_PUBLISHABLE_KEY=${projectKeys.publishableKey}`
- : `VITE_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
- '',
- ].join('\n')}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="utils/supabase.ts">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-import { createClient } from '@supabase/supabase-js';
-
-const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
-const supabaseKey = import.meta.env.${projectKeys.publishableKey ? 'VITE_SUPABASE_PUBLISHABLE_KEY' : 'VITE_SUPABASE_ANON_KEY'};
-
-const supabase = createClient(supabaseUrl, supabaseKey);
-
-export default supabase
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="App.tsx">
- <SimpleCodeBlock className="tsx" parentClassName="min-h-72">
- {`
-import { useState, useEffect } from 'react'
-import { supabase } from '../utils/supabase'
-
-function Page() {
- const [todos, setTodos] = useState([])
-
- useEffect(() => {
- function getTodos() {
- const { data: todos } = await supabase.from('todos').select()
-
- if (todos.length > 1) {
- setTodos(todos)
- }
- }
-
- getTodos()
- }, [])
-
- return (
- <div>
- {todos.map((todo) => (
- <li key={todo}>{todo}</li>
- ))}
- </div>
- )
-}
-export default Page
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/refine/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/refine/supabasejs/content.tsx
deleted file mode 100644
index 36493112614..00000000000
--- a/apps/studio/components/interfaces/Connect/content/refine/supabasejs/content.tsx
+++ /dev/null
@@ -1,117 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value=".env.local" />
- <ConnectTabTrigger value="src/utility/supabaseClient.ts" />
- <ConnectTabTrigger value="src/App.tsx" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value=".env.local">
- <SimpleCodeBlock className="bash" parentClassName="min-h-72">
- {[
- '',
- `SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
- `SUPABASE_KEY=${projectKeys?.publishableKey ?? projectKeys?.anonKey ?? 'your-anon-key'}`,
- '',
- ].join('\n')}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="src/utility/supabaseClient.ts">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-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,
- },
-});
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="src/App.tsx">
- <SimpleCodeBlock className="tsx" parentClassName="min-h-72">
- {`
-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;
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/remix/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/remix/supabasejs/content.tsx
deleted file mode 100644
index 8f65ce355d2..00000000000
--- a/apps/studio/components/interfaces/Connect/content/remix/supabasejs/content.tsx
+++ /dev/null
@@ -1,106 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value=".env" />
- <ConnectTabTrigger value="app/utils/supabase.server.ts" />
- <ConnectTabTrigger value="app/routes/_index.tsx" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value=".env">
- <SimpleCodeBlock className="bash" parentClassName="min-h-72">
- {[
- '',
- `VITE_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
- projectKeys?.publishableKey
- ? `VITE_SUPABASE_PUBLISHABLE_KEY=${projectKeys.publishableKey}`
- : `VITE_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
- '',
- ].join('\n')}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="app/utils/supabase.server.ts">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-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_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 };
-}
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="app/routes/_index.tsx">
- <SimpleCodeBlock className="tsx" parentClassName="min-h-72">
- {`
-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>
- </>
- );
-}
-
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/solidjs/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/solidjs/supabasejs/content.tsx
deleted file mode 100644
index 57dea50966a..00000000000
--- a/apps/studio/components/interfaces/Connect/content/solidjs/supabasejs/content.tsx
+++ /dev/null
@@ -1,75 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value=".env.local" />
- <ConnectTabTrigger value="utils/supabase.ts" />
- <ConnectTabTrigger value="src/App.jsx" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value=".env.local">
- <SimpleCodeBlock className="bash" parentClassName="min-h-72">
- {[
- '',
- `SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
- projectKeys?.publishableKey
- ? `SUPABASE_PUBLISHABLE_KEY=${projectKeys.publishableKey}`
- : `SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
- '',
- ].join('\n')}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="utils/supabase.ts">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-import { createClient } from "@supabase/supabase-js";
-
-const supabaseUrl = process.env.SUPABASE_URL;
-const supabaseKey = process.env.${projectKeys.publishableKey ? 'SUPABASE_PUBLISHABLE_KEY' : 'SUPABASE_ANON_KEY'};
-
-export const supabase = createClient(supabaseUrl!, supabaseKey!);
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="src/App.jsx">
- <SimpleCodeBlock className="jsx" parentClassName="min-h-72">
- {`
-import { supabase } from '../utils/supabase'
-import { createResource, For } from "solid-js";
-
-async function getTodos() {
- const { data: todos } = await supabase.from("todos").select();
- return data;
-}
-
-function App() {
- const [todos] = createResource(getTodos);
-
- return (
- <ul>
- <For each={todos()}>{(country) => <li>{todo.name}</li>}</For>
- </ul>
- );
-}
-
-export default App;
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/sveltekit/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/sveltekit/supabasejs/content.tsx
deleted file mode 100644
index ab13fb0546b..00000000000
--- a/apps/studio/components/interfaces/Connect/content/sveltekit/supabasejs/content.tsx
+++ /dev/null
@@ -1,82 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value=".env.local" />
- <ConnectTabTrigger value="src/lib/supabaseClient.js" />
- <ConnectTabTrigger value="src/routes/+page.server.js" />
- <ConnectTabTrigger value="src/routes/+page.svelte" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value=".env.local">
- <SimpleCodeBlock className="bash" parentClassName="min-h-72">
- {[
- '',
- `PUBLIC_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
- projectKeys?.publishableKey
- ? `PUBLIC_SUPABASE_PUBLISHABLE_KEY=${projectKeys.publishableKey}`
- : `PUBLIC_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
- '',
- ].join('\n')}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="src/lib/supabaseClient.js">
- <SimpleCodeBlock className="js" parentClassName="min-h-72">
- {`
-import { createClient } from "@supabase/supabase-js";
-import { PUBLIC_SUPABASE_URL, ${projectKeys.publishableKey ? 'PUBLIC_SUPABASE_PUBLISHABLE_KEY' : 'PUBLIC_SUPABASE_ANON_KEY'} } from "$env/static/public"
-
-const supabaseUrl = PUBLIC_SUPABASE_URL;
-const supabaseKey = ${projectKeys.publishableKey ? 'PUBLIC_SUPABASE_PUBLISHABLE_KEY' : 'PUBLIC_SUPABASE_ANON_KEY'};
-
-export const supabase = createClient(supabaseUrl, supabaseKey);
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="src/routes/+page.server.js">
- <SimpleCodeBlock className="js" parentClassName="min-h-72">
- {`
-import { supabase } from "$lib/supabaseClient";
-
-export async function load() {
- const { data } = await supabase.from("countries").select();
- return {
- countries: data ?? [],
- };
-}
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="src/routes/+page.svelte">
- <SimpleCodeBlock className="html" parentClassName="min-h-72">
- {`
-<script>
- export let data;
-</script>
-
-<ul>
- {#each data.countries as country}
- <li>{country.name}</li>
- {/each}
-</ul>
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/swift/supabaseswift/content.tsx b/apps/studio/components/interfaces/Connect/content/swift/supabaseswift/content.tsx
deleted file mode 100644
index 2fd5bf18cf4..00000000000
--- a/apps/studio/components/interfaces/Connect/content/swift/supabaseswift/content.tsx
+++ /dev/null
@@ -1,84 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value="Supabase.swift" />
- <ConnectTabTrigger value="Todo.swift" />
- <ConnectTabTrigger value="ContentView.swift" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value="Supabase.swift">
- <SimpleCodeBlock className="swift" parentClassName="min-h-72">
- {`
-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>'}"
-)
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="Todo.swift">
- <SimpleCodeBlock className="swift" parentClassName="min-h-72">
- {`
-import Foundation
-
-struct Todo: Identifiable, Decodable {
- var id: Int
- var title: String
-}
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="ContentView.swift">
- <SimpleCodeBlock className="swift" parentClassName="min-h-72">
- {`
-import Supabase
-import SwiftUI
-
-struct ContentView: View {
- @State var todos: [Todo] = []
-
- var body: some View {
- NavigationStack {
- List(todos) { todo in
- Text(todo.title)
- }
- .navigationTitle("Todos")
- .task {
- do {
- todos = try await supabase.from("todos").select().execute().value
- } catch {
- debugPrint(error)
- }
- }
- }
- }
-}
-
-#Preview {
- ContentView()
-}
-
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/tanstack/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/tanstack/supabasejs/content.tsx
deleted file mode 100644
index 2c36da5d106..00000000000
--- a/apps/studio/components/interfaces/Connect/content/tanstack/supabasejs/content.tsx
+++ /dev/null
@@ -1,74 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value=".env" />
- <ConnectTabTrigger value="src/utils/supabase.ts" />
- <ConnectTabTrigger value="src/routes/index.tsx" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value=".env">
- <SimpleCodeBlock className="bash" parentClassName="min-h-72">
- {`
-VITE_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
-VITE_SUPABASE_KEY=${projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'}
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="src/utils/supabase.ts">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-import { createClient } from "@supabase/supabase-js";
-
-export const supabase = createClient(
- import.meta.env.VITE_SUPABASE_URL,
- import.meta.env.VITE_SUPABASE_KEY
-);
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="src/routes/index.tsx">
- <SimpleCodeBlock className="tsx" parentClassName="min-h-72">
- {`
-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>
- )
-}
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/apps/studio/components/interfaces/Connect/content/vuejs/supabasejs/content.tsx b/apps/studio/components/interfaces/Connect/content/vuejs/supabasejs/content.tsx
deleted file mode 100644
index 70e70bc39a5..00000000000
--- a/apps/studio/components/interfaces/Connect/content/vuejs/supabasejs/content.tsx
+++ /dev/null
@@ -1,72 +0,0 @@
-import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
-
-import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
-import {
- ConnectTabContent,
- ConnectTabs,
- ConnectTabTrigger,
- ConnectTabTriggers,
-} from '@/components/interfaces/Connect/ConnectTabs'
-
-const ContentFile = ({ projectKeys }: ContentFileProps) => {
- return (
- <ConnectTabs>
- <ConnectTabTriggers>
- <ConnectTabTrigger value=".env.local" />
- <ConnectTabTrigger value="utils/supabase.ts" />
- <ConnectTabTrigger value="App.vue" />
- </ConnectTabTriggers>
-
- <ConnectTabContent value=".env.local">
- <SimpleCodeBlock className="bash" parentClassName="min-h-72">
- {`
-SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
-SUPABASE_KEY=${projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'}
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="utils/supabase.ts">
- <SimpleCodeBlock className="ts" parentClassName="min-h-72">
- {`
-import { createClient } from "@supabase/supabase-js";
-
-const supabaseUrl = process.env.SUPABASE_URL;
-const supabaseKey = process.env.SUPABASE_KEY;
-
-export const supabase = createClient(supabaseUrl, supabaseKey);
- `}
- </SimpleCodeBlock>
- </ConnectTabContent>
-
- <ConnectTabContent value="App.vue">
- <SimpleCodeBlock className="jsx" parentClassName="min-h-72">
- {`
-<script setup>
- 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>
-`}
- </SimpleCodeBlock>
- </ConnectTabContent>
- </ConnectTabs>
- )
-}
-
-export default ContentFile
diff --git a/knip.jsonc b/knip.jsonc
index 32c1d9dd9ff..072923cf961 100644
--- a/knip.jsonc
+++ b/knip.jsonc
@@ -9,8 +9,13 @@
"**/*.test.ts",
// ignore studio public folder
"apps/studio/public/**",
- // ignore studio components, they're dynamically imported
- "apps/studio/components/interfaces/Connect/content/**",
+ // ignore studio components that are dynamically imported
+ "apps/studio/components/interfaces/ConnectSheet/content/**",
+ "apps/studio/components/interfaces/ConnectSheet/ConnectionParameters.tsx",
+ "apps/studio/components/interfaces/ConnectSheet/DirectConnectionExamples.tsx",
+ "apps/studio/components/interfaces/ConnectSheet/useMcpUrl.ts",
+ // ignore studio data templates
+ "apps/studio/data/__templates/**",
// ignore registry blocks in ui-library
"apps/ui-library/registry/default/**",
"apps/ui-library/contentlayer.config.js",