| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414 |
- 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: 'brivenjs',
- label: 'briven-js',
- icon: 'briven',
- children: [],
- },
- ],
- },
- {
- key: 'pages',
- label: 'Pages Router',
- icon: '',
- children: [
- {
- key: 'brivenjs',
- label: 'Briven-js',
- children: [],
- icon: 'briven',
- },
- ],
- },
- ],
- },
- {
- key: 'remix',
- label: 'Remix',
- icon: 'remix',
- guideLink: `${DOCS_URL}/guides/auth/server-side/creating-a-client?framework=remix&environment=remix-loader`,
- children: [
- {
- key: 'brivenjs',
- label: 'Briven-js',
- children: [],
- icon: 'briven',
- },
- ],
- },
- {
- key: 'react',
- label: 'React',
- icon: 'react',
- guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/reactjs`,
- children: [
- {
- key: 'vite',
- label: 'Vite',
- icon: 'vite',
- children: [
- {
- key: 'brivenjs',
- label: 'Briven-js',
- children: [],
- icon: 'briven',
- },
- ],
- },
- {
- key: 'create-react-app',
- label: 'Create React App',
- icon: 'react',
- children: [
- {
- key: 'brivenjs',
- label: 'briven-js',
- icon: 'briven',
- children: [],
- },
- ],
- },
- ],
- },
- {
- key: 'nuxt',
- label: 'Nuxt',
- icon: 'nuxt',
- guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/nuxtjs`,
- children: [
- {
- key: 'brivenjs',
- label: 'Briven-js',
- children: [],
- icon: 'briven',
- },
- ],
- },
- {
- key: 'vuejs',
- label: 'Vue.JS',
- icon: 'vuejs',
- guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/vue`,
- children: [
- {
- key: 'brivenjs',
- label: 'Briven-js',
- children: [],
- icon: 'briven',
- },
- ],
- },
- {
- key: 'sveltekit',
- label: 'SvelteKit',
- icon: 'sveltekit',
- guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/sveltekit`,
- children: [
- {
- key: 'brivenjs',
- label: 'Briven-js',
- children: [],
- icon: 'briven',
- },
- ],
- },
- {
- key: 'solidjs',
- label: 'Solid.js',
- icon: 'solidjs',
- guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/solidjs`,
- children: [
- {
- key: 'brivenjs',
- label: 'Briven-js',
- children: [],
- icon: 'briven',
- },
- ],
- },
- {
- key: 'astro',
- label: 'Astro',
- icon: 'astro',
- guideLink: 'https://docs.astro.build/en/guides/backend/briven/',
- children: [
- {
- key: 'brivenjs',
- label: 'Briven-js',
- children: [],
- icon: 'briven',
- },
- ],
- },
- {
- key: 'refine',
- label: 'Refine',
- icon: 'refine',
- guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/refine`,
- children: [
- {
- key: 'brivenjs',
- label: 'Briven-js',
- children: [],
- icon: 'briven',
- },
- ],
- },
- {
- key: 'tanstack',
- label: 'TanStack Start',
- icon: 'tanstack',
- guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/tanstack`,
- children: [
- {
- key: 'brivenjs',
- label: 'Briven-js',
- children: [],
- icon: 'briven',
- },
- ],
- },
- {
- key: 'flask',
- label: 'Flask (Python)',
- icon: 'python',
- guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/flask`,
- children: [
- {
- key: 'brivenpy',
- label: 'briven-py',
- children: [],
- icon: 'briven',
- },
- ],
- },
- ]
- export const MOBILES: ConnectionType[] = [
- {
- key: 'exporeactnative',
- label: 'Expo React Native',
- icon: 'expo',
- guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/expo-react-native`,
- children: [
- {
- key: 'brivenjs',
- label: 'Briven-js',
- children: [],
- icon: 'briven',
- },
- ],
- },
- {
- key: 'flutter',
- label: 'Flutter',
- icon: 'flutter',
- guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-flutter`,
- children: [
- {
- key: 'brivenflutter',
- label: 'briven-flutter',
- children: [],
- icon: 'briven',
- },
- ],
- },
- {
- key: 'ionicreact',
- label: 'Ionic React',
- icon: 'react',
- guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-ionic-react`,
- children: [
- {
- key: 'brivenjs',
- label: 'Briven-js',
- children: [],
- icon: 'briven',
- },
- ],
- },
- {
- key: 'swift',
- label: 'Swift',
- icon: 'swift',
- guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-swift`,
- children: [
- {
- key: 'brivenswift',
- label: 'briven-swift',
- children: [],
- icon: 'briven',
- },
- ],
- },
- {
- key: 'androidkotlin',
- label: 'Android Kotlin',
- icon: 'kotlin',
- guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-kotlin`,
- children: [
- {
- key: 'brivenkt',
- label: 'briven-kt',
- children: [],
- icon: 'briven',
- },
- ],
- },
- {
- key: 'ionicangular',
- label: 'Ionic Angular',
- icon: 'ionic-angular',
- guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-ionic-angular`,
- children: [
- {
- key: 'brivenjs',
- label: 'Briven-js',
- children: [],
- icon: 'briven',
- },
- ],
- },
- ]
- 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.',
- },
- }
|