mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
## What kind of change does this PR introduce? Bug fix (documentation) — fixes #43920. ## What is the current behavior? The Drizzle connection example (`db.ts`) at [`apps/docs/content/guides/database/drizzle.mdx`](https://github.com/supabase/supabase/blob/master/apps/docs/content/guides/database/drizzle.mdx) does not compile or run as written: ```ts let connectionString = process.env.DATABASE_URL if (connectionString.includes('postgres:postgres@supabase_db_')) { const url = URL.parse(connectionString)! url.hostname = url.hostname.split('_')[1] connectionString = url.href } // ... export const db = drizzle(client); ``` - `process.env.DATABASE_URL` is `string | undefined`, so `.includes(...)` errors with **"Object is possibly 'undefined'"** — copy-pasting the snippet fails to type-check (the core of #43920). - `URL.parse()` is a very recent static method (Node 22.1+/modern runtimes only) and isn't portable for a docs example. - The final line ends with a stray `;`, which violates this repo's prettier config (`semi: false`). ## What is the new behavior? Three surgical fixes to the snippet: ```ts let connectionString = process.env.DATABASE_URL! if (connectionString.includes('postgres:postgres@supabase_db_')) { const url = new URL(connectionString) url.hostname = url.hostname.split('_')[1] connectionString = url.href } // ... export const db = drizzle(client) ``` - `DATABASE_URL!` — the example assumes the env var is set (it's set in the step above), matching Drizzle's own docs. - `new URL(connectionString)` — standard and portable. - Dropped the trailing semicolon to satisfy `semi: false`. No prose changes; the docker hostname-rewrite logic is unchanged. ## Validation The corrected snippet is **prettier-clean** under this repo's config (`semi: false`, `singleQuote: true`, `printWidth: 100`) — verified idempotent with `prettier --parser typescript`. The change is a single code block in one MDX file. ## Additional context Fixes #43920. The undefined-variable / type-unsafe form was introduced in #40288. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Updated Drizzle database quickstart: added explicit validation for the DATABASE_URL environment variable and improved connection-string parsing to better handle Docker/Supabase hostnames, plus clarified client/DB initialization steps. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Reference Docs
Supabase Reference Docs
Maintainers
If you are a maintainer of any tools in the Supabase ecosystem, you can use this site to provide documentation for the tools & libraries that you maintain.
DocSpec
We use documentation specifications which can be used to generate human-readable docs.
- OpenAPI: for documenting API endpoints.
- SDKSpec (custom to Supabase): for SDKs and client libraries.
- ConfigSpec (custom to Supabase): for configuration options.
- CLISpec (custom to Supabase): for CLI commands and usage.
The benefit of using custom specifications is that we can generate many other types from a strict schema (eg, HTML and manpages). It also means that we can switch to any documentation system we want. On this site we use Next.js, but on Supabase's official website, we use a custom React site and expose only a subset of the available API for each tool.
Contributing
To contribute to docs, see the developers' guide and contributing guide.