mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
Two page templates still served their main content only after JavaScript
ran, so crawlers that don't run it never saw it. The /open-source repo
cards came from a GitHub fetch in a `useEffect`. The library docs
install command and the default code view on the client pages were
`dynamic(..., { ssr: false })`.
**Changed:**
- **/open-source repo cards render in the HTML**: I added
`getStaticProps` with hourly ISR that fetches the org repos once, keeps
only the repos the tabs list, and seeds `Repos`. Any failure (non-2xx,
timeout, unexpected body) falls back to `null`, which keeps today's
client fetch, and that result is cached for 60s so a rate-limited
regeneration heals quickly. I made counts format as `en-US` until
hydration so non-US browsers don't hit a hydration mismatch, and I
switched the star sort to a consistent comparator so ties hydrate in the
same order in every engine.
- **Library docs install command renders on the server**: I made the
app's `useLocalStorage` read storage in a layout effect instead of the
`useState` initializer, so `Command` no longer needs `ssr: false`.
Returning users who picked another package manager see npm until
hydration, then their choice, where before the box was empty until then.
- **Library docs code shows instead of "Loading code preview..."**: I
kept `CodeBlock` client-only because it reads the resolved theme, and I
changed its loading fallback to render the selected file's code in a
plain `<pre>`.
**Note:** the GitHub fetch is unauthenticated, since the www project has
no general-purpose GitHub token. If regeneration keeps getting
rate-limited, adding a read-only token to the www env is a few-line
follow-up.
## To test
Tested on the PR previews, compared with prod:
- [x] `curl -sL` /open-source with a Chrome user agent and strip
`<script>`, `<style>` and `<template>`: supabase, supabase-js,
supavisor, postgres and postgres-meta appear with their descriptions
(prod has no repo cards).
- [x] `curl -sL` /open-source and read the `__NEXT_DATA__` JSON: every
name in `repos` appears in the page's tabs.
- [x] On /open-source with the browser language set to German: the
Database tab shows the same cards in the same order as prod, counts use
German separators after load, the browser makes no GitHub API request,
and the console shows no hydration error.
- [x] Switch to the Auth and Other tabs: the same cards as prod. Repos
with equal star counts can appear in a different order.
- [x] `curl -sL` /library/docs/nextjs/client the same way:
`createBrowserClient` is present in a plain `<pre>` (prod shows "Loading
code preview...").
- [x] `curl -sL` a block page such as
/library/docs/nextjs/password-based-auth: the `npx shadcn@latest add`
command is present (prod has none).
- [x] On a block page, pick pnpm in the install command and reload: pnpm
stays selected, with no hydration error.
- [x] On /library/docs/nextjs/client after load, in light and dark
theme: the highlighted code block matches prod, with line numbers.
- [x] No hydration warnings in the console on any of these pages.
## Linear
- part of GROWTH-1416