Part 4 of a 6-PR stack migrating all `next/router` and
`next/compat/router` imports in `apps/studio` onto TanStack Router hooks
and removing the router shims.
| Part | PR | Scope |
| --- | --- | --- |
| 1 | #54053 | Core navigation helpers, `hooks/**`, `lib/**`,
`data/prefetchers/**` |
| 2 | #54054 | `components/ui/**` |
| 3 | #54055 | `components/layouts/**` and `state/tabs.tsx` |
| **4** | **#54056 ← this PR** | **Database, Branching, Compute, Edge
Functions, Explorer, SQL Editor, Storage, Table Editor** |
| 5 | #54057 | Remaining `components/interfaces/**` and
`QueryInsightsTable` router events |
| 6 | #54058 | Remove `next/router` & `next/compat/router` shims,
`_router-events.ts`, Vite aliases, and test mocks |
Migrates the database, branching, compute, functions, explorer, SQL
editor, storage, and table editor interfaces off `next/router` and
`next/compat/router`.
**Changed:**
- Migrated the sole `next/compat/router` consumer
(`components/interfaces/Database/Replication/Destinations.tsx`) to
`useNavigate`
- Replaced `useRouter` across `BranchManagement`, `Branching`,
`Compute`, `Database` (`Backups`, `Functions`, `Replication`, `Schemas`,
`Tables`, `Triggers`), `EdgeFunctions`, `Explorer`, `Functions`,
`SQLEditor`, `Storage` (`AnalyticsBuckets`, `FilesBuckets`,
`VectorBuckets`, `StorageMenuV2`, `Storage.utils`), and
`TableGridEditor` with TanStack Router hooks (`useNavigate`,
`useLocation`, `useRoutePattern`) and `useParams` from `common`
- Updated unit and component tests across `Database/Replication`,
`Explorer`, `Functions`, and
`Storage/FilesBuckets/DeleteBucketModal.test.tsx` to use TanStack Router
**Simplified:**
- `useSnippetEditor` and `useRedirectLegacyReadReplicaDestination` read
search values from `useParams` instead of casting `location.search`
- `resolveSourceSwitch` returns `replace: boolean` instead of a
`push`/`replace` method name
- `ExplorerQueryTab` and `EdgeFunctionDetails` guard on a defined ref
instead of navigating with `ref ?? ''`
- `useFunctionsDetailShortcuts` and `StorageMenuV2` use a local `goTo`
helper for their navigation shortcuts
- Tests use the shared `createTestRouter` and `customRender` router, use
`toMatchObject` for search assertions, and drop duplicate assertions
Addresses
[FE-5109](https://linear.app/supabase/issue/FE-5109/replace-the-nextrouter-shims-with-tanstack-router-hooks)
## To test
- [ ] SQL Editor: creating, renaming, moving, opening
templates/examples, and keyboard shortcuts navigate between snippets
cleanly
- [ ] Table Editor & Database: opening tables, schema table nodes,
triggers, functions, backups/PITR, and replication destination flows
navigate as expected
- [ ] Storage: switching between Files, Analytics, and Vector buckets
and deleting a bucket navigates cleanly
- [ ] Edge Functions & Explorer: opening function details/logs, explorer
chat/query tabs, and branch management actions navigate properly
---------
Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
## Context
We've been seeing many `NotFoundError: Failed to execute 'removeChild'
on 'Node'` and `NotFoundError: Failed to execute 'insertBefore' on
'Node'` events on Sentry which are historically known to be caused by
Google Translate in the browser.
There's technically no _right way_ to address this unfortunately, but
one of the solutions which should address most of these issues is to
wrap any dynamic text within a span - we've considered that quite a
while back tbh but never took the time to do this until today with the
help of Claude. Although just a heads up that it might not necessarily
completely eradicate those issues.
Also added an eslint rule which should prevent future occurences of this
<img width="1264" height="192" alt="image"
src="https://github.com/user-attachments/assets/b2c32ea0-45a2-4ccd-82fe-1a859905fc29"
/>
## Problem
Deleting a bucket from its own page
(`/storage/files/buckets/[bucketId]`) could leave Studio on the deleted
bucket's route. The page kept loading and then showed "Failed to fetch
buckets" / "Bucket not found".
On success, `DeleteBucketModal` called `onClose()` and then
`router.push` to the buckets list. On the bucket page, `onClose` clears
the `?delete` query param through nuqs, which queues its own shallow
push to the current bucket URL. That push could race with the navigation
to the list and land back on the deleted bucket. The page then
re-rendered with the bucket query already removed from the cache,
refetched the missing bucket, and got a 404.
## Solution
- On the bucket's own page, the success handler now awaits `router.push`
to the buckets list and does not call `onClose`. The modal closes when
the page unmounts. When there is no `bucketId` in the route, it still
calls `onClose` as before.
- Added a component test for deleting from the bucket page. It checks
that Studio ends up on `/project/<ref>/storage/files` and that `onClose`
is not called. The test opts out of the global `useParams` stub so the
modal reads `bucketId` from the mocked route. It fails without the fix.
## How to verify
1. Open a project, go to Storage > Files, and open any bucket.
2. Choose Edit bucket > Delete bucket, type the bucket name, and
confirm.
3. Studio shows the success toast and lands on the buckets list
(`/project/<ref>/storage/files`). The deleted bucket no longer appears
there.
4. Studio never shows the deleted bucket's page with a spinner that
keeps loading, "Failed to fetch buckets" or "Bucket not found".
## Checks run
- `pnpm --filter studio exec vitest run
components/interfaces/Storage/FilesBuckets/DeleteBucketModal.test.tsx`
(2 passed)
- `pnpm turbo run typecheck --filter='...[origin/master]'`
- `pnpm turbo run lint --filter='[origin/master]'`
- Prettier check on the changed files
[FE-4926](https://linear.app/supabase/issue/FE-4926/deleting-a-bucket-leaves-its-page-loading-until-an-error)
---------
Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com>
## Problem
Studio's storage policy parser (\`extractBucketNameFromDefinition\`)
returned only the first quoted string near \`bucket_id\` and ignored the
operator. As a result:
- Policies covering several buckets (\`bucket_id in ('a', 'b')\`) were
listed and counted under the first bucket only.
- Negated policies (\`bucket_id <> 'a'\`) were attributed to the
excluded bucket.
- \`DeleteBucketModal\` could delete a negated or shared policy that
still protects other buckets.
Fixes FE-3993, supabase/supabase#48164.
Before:
<img width="884" height="444" alt="Screenshot 2026-11-03 at 10 46 08"
src="https://github.com/user-attachments/assets/fc6e4842-b07f-40be-8057-b94f4034e4eb"
/>
After (same data):
<img width="891" height="515" alt="Screenshot 2026-11-03 at 10 46 21"
src="https://github.com/user-attachments/assets/47248b30-a309-4774-8349-05260ad02111"
/>
## Solution
- Replace the parser with \`extractBucketNamesFromDefinition\`, which
returns every bucket referenced via \`=\`, \`= ANY (ARRAY[...])\` and
\`OR\`, and returns none for negated conditions (those fall into
Ungrouped).
- Add \`getPolicyBucketNames\`, which combines \`definition\` and
\`check\`, and use it in the Policies page grouping,
\`useBucketPolicyCount\`, and \`DeleteBucketModal\` so they agree.
- A policy is now listed under each bucket it covers.
- Bucket deletion only removes policies whose sole target is the deleted
bucket. Shared and negated policies are left in place. This is the
conservative choice: an unparsed policy is left behind, never deleted.
- Added unit tests for the parser shapes, negation, \`check\`-only
policies, and grouping.
## This PR
Adds **Show archived** to the file explorer's view options and list them
in the file explorer.
- `useStoragePreference` — `showArchivedInline`, stored per project
- `ArchivedFilesContext` — owns the archived list and which object is
selected
- `FileExplorer` — merges archived rows into each column and re-sorts,
since the server-side sort never sees them
- `FileExplorerRow` — dimmed striped rendering, no checkbox, no context
menu
- `FileExplorerHeader` — the toggle, rendered only behind the feature
preview
- `StorageExplorer` — mounts the provider
https://github.com/user-attachments/assets/a26551b4-b22d-485e-9d23-3e78c4a89315
Clicking an archived row opens a preview panel: where the file used to
live, when it was archived, its retained versions, and the actions to
bring it back or delete it permanently.
- `ArchivedFilePreviewPane` — the pane, replacing `PreviewPane` while an
archived row is selected
- `ArchivedVersionRestoreWidget` — takes over the top of the pane when a
specific retained version is selected
- `ArchivedVersionRow` — one version, with its restore / delete actions
- `StorageExplorerContent` — the pane swap
https://github.com/user-attachments/assets/03c9eae6-e9e3-4bd0-8145-953625e125d1
Other additions behind the feature preview:
- The buckets list show a **Versioning** column.
- `BucketVersioningPill` — a `file-stack` badge beside the bucket name
in the breadcrumbs, brand when versioning is enabled and warning when it
is suspended, so the bucket's state is visible from inside the explorer
rather than only from the buckets list.
https://github.com/user-attachments/assets/f4827aac-a9ff-4300-92ac-073848d63606
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>