Connect.constants.ts413 lines · main
1import { type CodeBlockLang } from 'ui-patterns/CodeBlock'
2
3import { DOCS_URL } from '@/lib/constants'
4
5export type DatabaseConnectionType =
6 | 'uri'
7 | 'psql'
8 | 'golang'
9 | 'jdbc'
10 | 'dotnet'
11 | 'nodejs'
12 | 'php'
13 | 'python'
14 | 'sqlalchemy'
15
16export const DATABASE_CONNECTION_TYPES: {
17 id: DatabaseConnectionType
18 label: string
19 contentType: 'input' | 'code'
20 lang: CodeBlockLang
21 fileTitle: string | undefined
22}[] = [
23 { id: 'uri', label: 'URI', contentType: 'input', lang: 'bash', fileTitle: undefined },
24 { id: 'psql', label: 'PSQL', contentType: 'code', lang: 'bash', fileTitle: undefined },
25 { id: 'golang', label: 'Golang', contentType: 'code', lang: 'go', fileTitle: '.env' },
26 { id: 'jdbc', label: 'JDBC', contentType: 'input', lang: 'bash', fileTitle: undefined },
27 {
28 id: 'dotnet',
29 label: '.NET',
30 contentType: 'code',
31 lang: 'csharp',
32 fileTitle: 'appsettings.json',
33 },
34 { id: 'nodejs', label: 'Node.js', contentType: 'code', lang: 'js', fileTitle: '.env' },
35 { id: 'php', label: 'PHP', contentType: 'code', lang: 'php', fileTitle: '.env' },
36 { id: 'python', label: 'Python', contentType: 'code', lang: 'python', fileTitle: '.env' },
37 { id: 'sqlalchemy', label: 'SQLAlchemy', contentType: 'code', lang: 'python', fileTitle: '.env' },
38]
39
40export const CONNECTION_PARAMETERS = {
41 host: {
42 key: 'host',
43 description: 'The hostname of your database',
44 },
45 port: {
46 key: 'port',
47 description: 'Port number for the connection',
48 },
49 database: {
50 key: 'database',
51 description: 'Default database name',
52 },
53 user: {
54 key: 'user',
55 description: 'Database user',
56 },
57 pool_mode: {
58 key: 'pool_mode',
59 description: 'Connection pooling behavior',
60 },
61} as const
62
63export type ConnectionType = {
64 key: string
65 icon: string
66 label: string
67 guideLink?: string
68 children: ConnectionType[]
69 files?: {
70 name: string
71 content: string
72 }[]
73}
74
75export const FRAMEWORKS: ConnectionType[] = [
76 {
77 key: 'nextjs',
78 label: 'Next.js',
79 icon: 'nextjs',
80 guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/nextjs`,
81 children: [
82 {
83 key: 'app',
84 label: 'App Router',
85 icon: '',
86 children: [
87 {
88 key: 'brivenjs',
89 label: 'briven-js',
90 icon: 'briven',
91 children: [],
92 },
93 ],
94 },
95 {
96 key: 'pages',
97 label: 'Pages Router',
98 icon: '',
99 children: [
100 {
101 key: 'brivenjs',
102 label: 'Briven-js',
103 children: [],
104 icon: 'briven',
105 },
106 ],
107 },
108 ],
109 },
110 {
111 key: 'remix',
112 label: 'Remix',
113 icon: 'remix',
114 guideLink: `${DOCS_URL}/guides/auth/server-side/creating-a-client?framework=remix&environment=remix-loader`,
115 children: [
116 {
117 key: 'brivenjs',
118 label: 'Briven-js',
119 children: [],
120 icon: 'briven',
121 },
122 ],
123 },
124 {
125 key: 'react',
126 label: 'React',
127 icon: 'react',
128 guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/reactjs`,
129 children: [
130 {
131 key: 'vite',
132 label: 'Vite',
133 icon: 'vite',
134 children: [
135 {
136 key: 'brivenjs',
137 label: 'Briven-js',
138 children: [],
139 icon: 'briven',
140 },
141 ],
142 },
143 {
144 key: 'create-react-app',
145 label: 'Create React App',
146 icon: 'react',
147 children: [
148 {
149 key: 'brivenjs',
150 label: 'briven-js',
151 icon: 'briven',
152 children: [],
153 },
154 ],
155 },
156 ],
157 },
158 {
159 key: 'nuxt',
160 label: 'Nuxt',
161 icon: 'nuxt',
162 guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/nuxtjs`,
163 children: [
164 {
165 key: 'brivenjs',
166 label: 'Briven-js',
167 children: [],
168 icon: 'briven',
169 },
170 ],
171 },
172 {
173 key: 'vuejs',
174 label: 'Vue.JS',
175 icon: 'vuejs',
176 guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/vue`,
177 children: [
178 {
179 key: 'brivenjs',
180 label: 'Briven-js',
181 children: [],
182 icon: 'briven',
183 },
184 ],
185 },
186
187 {
188 key: 'sveltekit',
189 label: 'SvelteKit',
190 icon: 'sveltekit',
191 guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/sveltekit`,
192 children: [
193 {
194 key: 'brivenjs',
195 label: 'Briven-js',
196 children: [],
197 icon: 'briven',
198 },
199 ],
200 },
201 {
202 key: 'solidjs',
203 label: 'Solid.js',
204 icon: 'solidjs',
205 guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/solidjs`,
206 children: [
207 {
208 key: 'brivenjs',
209 label: 'Briven-js',
210 children: [],
211 icon: 'briven',
212 },
213 ],
214 },
215 {
216 key: 'astro',
217 label: 'Astro',
218 icon: 'astro',
219 guideLink: 'https://docs.astro.build/en/guides/backend/briven/',
220 children: [
221 {
222 key: 'brivenjs',
223 label: 'Briven-js',
224 children: [],
225 icon: 'briven',
226 },
227 ],
228 },
229 {
230 key: 'refine',
231 label: 'Refine',
232 icon: 'refine',
233 guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/refine`,
234 children: [
235 {
236 key: 'brivenjs',
237 label: 'Briven-js',
238 children: [],
239 icon: 'briven',
240 },
241 ],
242 },
243 {
244 key: 'tanstack',
245 label: 'TanStack Start',
246 icon: 'tanstack',
247 guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/tanstack`,
248 children: [
249 {
250 key: 'brivenjs',
251 label: 'Briven-js',
252 children: [],
253 icon: 'briven',
254 },
255 ],
256 },
257 {
258 key: 'flask',
259 label: 'Flask (Python)',
260 icon: 'python',
261 guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/flask`,
262 children: [
263 {
264 key: 'brivenpy',
265 label: 'briven-py',
266 children: [],
267 icon: 'briven',
268 },
269 ],
270 },
271]
272
273export const MOBILES: ConnectionType[] = [
274 {
275 key: 'exporeactnative',
276 label: 'Expo React Native',
277 icon: 'expo',
278 guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/expo-react-native`,
279 children: [
280 {
281 key: 'brivenjs',
282 label: 'Briven-js',
283 children: [],
284 icon: 'briven',
285 },
286 ],
287 },
288 {
289 key: 'flutter',
290 label: 'Flutter',
291 icon: 'flutter',
292 guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-flutter`,
293 children: [
294 {
295 key: 'brivenflutter',
296 label: 'briven-flutter',
297 children: [],
298 icon: 'briven',
299 },
300 ],
301 },
302 {
303 key: 'ionicreact',
304 label: 'Ionic React',
305 icon: 'react',
306 guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-ionic-react`,
307 children: [
308 {
309 key: 'brivenjs',
310 label: 'Briven-js',
311 children: [],
312 icon: 'briven',
313 },
314 ],
315 },
316 {
317 key: 'swift',
318 label: 'Swift',
319 icon: 'swift',
320 guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-swift`,
321 children: [
322 {
323 key: 'brivenswift',
324 label: 'briven-swift',
325 children: [],
326 icon: 'briven',
327 },
328 ],
329 },
330 {
331 key: 'androidkotlin',
332 label: 'Android Kotlin',
333 icon: 'kotlin',
334 guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-kotlin`,
335 children: [
336 {
337 key: 'brivenkt',
338 label: 'briven-kt',
339 children: [],
340 icon: 'briven',
341 },
342 ],
343 },
344 {
345 key: 'ionicangular',
346 label: 'Ionic Angular',
347 icon: 'ionic-angular',
348 guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-ionic-angular`,
349 children: [
350 {
351 key: 'brivenjs',
352 label: 'Briven-js',
353 children: [],
354 icon: 'briven',
355 },
356 ],
357 },
358]
359
360export const ORMS: ConnectionType[] = [
361 {
362 key: 'prisma',
363 label: 'Prisma',
364 icon: 'prisma',
365 guideLink: 'https://supabase.com/partners/integrations/prisma',
366 children: [],
367 },
368 {
369 key: 'drizzle',
370 label: 'Drizzle',
371 icon: 'drizzle',
372 guideLink: `${DOCS_URL}/guides/database/connecting-to-postgres#connecting-with-drizzle`,
373 children: [],
374 },
375]
376
377export const CONNECTION_TYPES = [
378 { key: 'direct', label: 'Connection String', obj: [] },
379 { key: 'frameworks', label: 'App Frameworks', obj: FRAMEWORKS },
380 { key: 'mobiles', label: 'Mobile Frameworks', obj: MOBILES },
381 { key: 'orms', label: 'ORMs', obj: ORMS },
382 { key: 'mcp', label: 'MCP', obj: [] },
383]
384
385export const PGBOUNCER_ENABLED_BUT_NO_IPV4_ADDON_TEXT =
386 'Purchase IPv4 add-on or use Shared Pooler if on a IPv4 network'
387export const IPV4_ADDON_TEXT = 'Connections are IPv4 proxied with IPv4 add-on'
388
389export type ConnectionStringMethod = 'direct' | 'transaction' | 'session'
390
391export const connectionStringMethodOptions: Record<
392 ConnectionStringMethod,
393 { value: string; label: string; description: string }
394> = {
395 direct: {
396 value: 'direct',
397 label: 'Direct connection',
398 description:
399 'Ideal for applications with persistent and long-lived connections, such as those running on virtual machines or long-standing containers.',
400 },
401 transaction: {
402 value: 'transaction',
403 label: 'Transaction pooler',
404 description:
405 'Ideal for stateless applications like serverless functions where each interaction with Postgres is brief and isolated.',
406 },
407 session: {
408 value: 'session',
409 label: 'Session pooler',
410 description:
411 'Only recommended as an alternative to Direct Connection, when connecting via an IPv4 network.',
412 },
413}