## Problem Several: - using above recommended # of redirects in the apps/www configuration -- currently around ~1275, so 275 above the recommended limit -- which leads to degraded performance for _every_ request going through the first zone (including the dashboard, I'd think). ``` www:build: www:build:next: Warning: total number of custom routes exceeds 1000, this can reduce performance. Route counts: ``` - We want to add more redirects over time. The current approach doesn't allow us to do so without cost. - No ability to test docs redirects in previews, which makes reviewing and merging in changes riskier than it should be. The fact that we _can_ test the changes in this PR is a huge improvement. ## Solution Diff approach, but related to #51193 Moves docs redirects into the docs app directly, splitting them between [next.config.mjs](https://vercel.com/docs/routing/redirects/configuration-redirects) (dynamic) and [Vercel's bulk redirects](https://vercel.com/docs/routing/redirects/bulk-redirects) (static). ```txt apps/ ├── docs/ │ ├── lib/ │ │ └── redirects/ │ │ ├── README.md # process and rules for adding redirects │ │ ├── static-redirects.json # source: one-to-one /docs entries (hand-edited) │ │ ├── dynamic-redirects.js # conditional /docs entries + dev/preview rules │ │ └── generated/ │ │ └── static-redirects-md-variants.json # .md guides variants generated in pre-build ``` B/c this -- in itself -- also puts us above the 1000 redirects, separates out redirects based on their _type_: - Dynamic redirects, live in a .js folder -> referenced in next.config.mjs. These are not support - Static redirects live in a json folder (required for Vercel bulk redirects) -> then referenced in the vercel.json config Also adds `.md` variant logic to both -- we can actually see a _lot_ of these paths are hit within analytics. Quick sample over the past 24 hours: ``` path, code, # of hits /docs/guides/monitoring-and-debugging.md 308 1768 /docs/guides/api/api-keys.md 308 722 /docs/guides/auth/server-side/nextjs.md 307 381 /docs/guides/auth/social-login/auth-google.md 308 231 /docs/guides/getting-started/mcp.md 308 218 /kb/troubleshooting/formatting-support-requests-for-faster-resolution.md 308 159 /docs/guides/troubleshooting/formatting-support-requests-for-faster-resolution-616717.md 308 156 /docs/guides/local-development/overview.md 308 139 /docs/guides/telemetry/logs.md 308 129 /kb/sitemap.md 308 117 /docs/guides/auth/social-login/auth-apple.md 308 103 /kb/troubleshooting/rotating-anon-service-and-jwt-secrets-1Jq6yd.md 308 97 ``` The exact method for generating these .md variants could use a sanity check: - Dynamic - follows the existing logic from the apps/www - Static - adds a prebuild script to automatically create .md variants for `/docs/guides` links. I _think_ this will work even though the output is gitignored by default... but remains to be seen. ## Preview links - [Dynamic path, no .md](https://docs-git-kody-devrel-723-redirects-rework-supabase.vercel.app/docs/guides/reports/reports) - [Dynamic path, .md](https://docs-git-kody-devrel-723-redirects-rework-supabase.vercel.app/docs/guides/reports/reports.md) - [Static path, no .md](https://docs-git-kody-devrel-723-redirects-rework-supabase.vercel.app/docs/guides/api/joins-and-nesting) - [Static path, .md](https://docs-git-kody-devrel-723-redirects-rework-supabase.vercel.app/docs/guides/api/joins-and-nesting.md) ## Builds <img width="1128" height="289" alt="image" src="https://github.com/user-attachments/assets/3cbbb111-e7b8-4922-ba8c-23cbc0bb3ddc" /> ## Go-live - [ ] Sign off on restructure from Growth Eng + Docs team. - [ ] Reviewer double-check with agent that a) this contains largely the same set as the current set in www and b) that these resolve to 200s. For a, there are a few small differences due to cleanup + re-ordering redirects that didn't previously work. - [ ] In the docs project, purchase a batch of 25,000 bulk redirects in Vercel (builds fail if you don't have the quota with `Bulk redirects limit exceeded. Attempting to add 1,013 redirects to a deployment, but only 1,000 available. Visit https://vercel.com/supabase/docs/settings/advanced#bulk-redirects to increase bulk redirects capacity.`) - [ ] Move the disabled redirects back into the main folder, and confirm builds work. - [x] Update `write-the-docs` skill to mention redirects --------- Co-authored-by: Claude Haiku 5.5 <noreply@anthropic.com>
1.7 KiB
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.
Redirects
Redirects for /docs URLs live in lib/redirects/. Static one-to-one entries go in static-redirects.json, conditional entries go in dynamic-redirects.js, and the .md variants for /docs/guides/ entries are generated at build time. Read that README before adding or changing a redirect.
Contributing
To contribute to docs, see the style guide for how to write a page, and the developers' guide and contributing guide for repo mechanics. If you write with an AI coding agent, use the /write-the-docs skill to draft and /edit-the-docs to revise an existing page.