Skip to content

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

docs: fix broken Drizzle connection snippet (#43920) (#46894)

Syed Osama Ali Shahc11411e2c693
diff --git a/apps/docs/content/guides/database/drizzle.mdx b/apps/docs/content/guides/database/drizzle.mdx
index 852e0d356f4..c9a58a1554e 100644
--- a/apps/docs/content/guides/database/drizzle.mdx
+++ b/apps/docs/content/guides/database/drizzle.mdx
@@ -80,16 +80,19 @@ If you plan on solely using Drizzle instead of the Supabase Data API (PostgREST)
import { drizzle } from 'drizzle-orm/postgres-js'
import postgres from 'postgres'
- let connectionString = process.env.DATABASE_URL
+ const databaseUrl = process.env.DATABASE_URL
+ if (!databaseUrl) throw new Error('DATABASE_URL is not set')
+
+ let connectionString = databaseUrl
if (connectionString.includes('postgres:postgres@supabase_db_')) {
- const url = URL.parse(connectionString)!
+ const url = new URL(connectionString)
url.hostname = url.hostname.split('_')[1]
connectionString = url.href
}
// Disable prefetch as it is not supported for "Transaction" pool mode
export const client = postgres(connectionString, { prepare: false })
- export const db = drizzle(client);
+ export const db = drizzle(client)
```
</StepHikeCompact.Code>