diff --git a/.agents/skills/dev-toolbar-review/SKILL.md b/.agents/skills/dev-toolbar-review/SKILL.md
index fae84992088..687fcd09680 100644
--- a/.agents/skills/dev-toolbar-review/SKILL.md
+++ b/.agents/skills/dev-toolbar-review/SKILL.md
@@ -94,7 +94,7 @@ server-side telemetry. Uses exponential backoff on connection errors.
**Provider + toolbar panel** (`DevToolbarProvider`, `DevToolbar`):
-- `apps/studio/pages/_app.tsx`
+- `apps/studio/routes/__root.tsx`
- `apps/www/pages/_app.tsx`, `apps/www/app/providers.tsx`
- `apps/docs/features/app.providers.tsx`
diff --git a/.agents/skills/studio-mock-api-tests/SKILL.md b/.agents/skills/studio-mock-api-tests/SKILL.md
index a3b8524deed..3016d564c67 100644
--- a/.agents/skills/studio-mock-api-tests/SKILL.md
+++ b/.agents/skills/studio-mock-api-tests/SKILL.md
@@ -149,11 +149,17 @@ customRender(, { profileContext: PROFILE_CONTEXT })
### 5. `useParams` is globally mocked to `{ ref: 'default' }`
-You don't need to mock the Next router for project-scoped components.
+You don't need to configure a router for project-scoped components.
Just use `'default'` as the project ref in your mock paths:
`/v1/projects/default/secrets`, `/platform/projects/default/...`. If
-you need a different ref, override with `routerMock.setCurrentUrl(...)`
-(see `apps/studio/tests/lib/route-mock.ts`).
+you need a different ref or dynamic route params read via `useParams`
+from `'common'`, render the route with `renderRoute`
+(`apps/studio/tests/lib/route-render.tsx`), which provides
+`RenderedRouteContext` so the global `useParams` mock delegates to the
+real hook. Passing `initialUrl` or `router` to `customRender` alone
+still returns `{ ref: 'default' }` from `common`'s `useParams` (it only
+drives TanStack Router hooks and `useFramework()`, unless the test also
+restores the real `useParams` implementation).
### 6. Unhandled requests fail loudly — mock every endpoint a render triggers
diff --git a/.agents/skills/studio-testing/SKILL.md b/.agents/skills/studio-testing/SKILL.md
index 5569018bfd8..bfd4fa9838e 100644
--- a/.agents/skills/studio-testing/SKILL.md
+++ b/.agents/skills/studio-testing/SKILL.md
@@ -194,7 +194,7 @@ verification evidence without changing source or introducing mutations.
| Component test examples | `apps/studio/tests/features/logs/LogsFilterPopover.test.tsx`, `apps/studio/tests/components/CopyButton.test.tsx` |
| Fake timers (polling) | `apps/studio/components/layouts/ProjectLayout/RestoringState.test.tsx` |
| Fake timers (debounce) | `apps/studio/hooks/misc/__tests__/useTableEditorFiltersSort.navigation.test.tsx` |
-| Scoped listbox queries | `apps/studio/tests/pages/new/[slug].test.tsx`, `apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/ResourceAccessStep.test.tsx` |
+| Scoped listbox queries | `apps/studio/tests/routes/new/$slug.test.tsx`, `apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/ResourceAccessStep.test.tsx` |
| E2E test example | `e2e/studio/features/filter-bar.spec.ts` |
| E2E helpers pattern | `e2e/studio/utils/filter-bar-helpers.ts` |
| Custom render | `apps/studio/tests/lib/custom-render.tsx` |
diff --git a/.github/workflows/studio-e2e-test.yml b/.github/workflows/studio-e2e-test.yml
index fd75587480f..a9e90fb3179 100644
--- a/.github/workflows/studio-e2e-test.yml
+++ b/.github/workflows/studio-e2e-test.yml
@@ -119,15 +119,13 @@ jobs:
# the API URL, fixed by e2e/studio/supabase/config.toml. So build
# against that URL and check it against the real value once supabase is up.
#
- # `MODE=test` so the Vite build loads `.env.test` for env resolution.
- # `vite.config.ts` overrides the bundle NODE_ENV to 'production'
- # regardless of input, so vitest-only constants (e.g. `API_URL`)
- # don't bleed in here.
+ # `MODE=test` so the Vite build loads `.env.test` for env resolution
+ # while Vite keeps `NODE_ENV=production` for the bundle.
run: |
echo '{"API_URL":"http://127.0.0.1:54321"}' > keys.json
node scripts/generateLocalEnv.js
grep '^NEXT_PUBLIC_' apps/studio/.env.test | sort > "$RUNNER_TEMP/build-public-env"
- SKIP_ASSET_UPLOAD=1 NODE_ENV=test MODE=test NODE_OPTIONS="--max-old-space-size=4096" pnpm run build:studio
+ SKIP_ASSET_UPLOAD=1 MODE=test NODE_OPTIONS="--max-old-space-size=4096" pnpm run build:studio
- name: Wait for supabase and Playwright browsers
wait: [supabase, playwright-install]
diff --git a/apps/studio/.env b/apps/studio/.env
index 89fbeb4f7c9..014d601f5e6 100644
--- a/apps/studio/.env
+++ b/apps/studio/.env
@@ -19,7 +19,6 @@ LOGFLARE_URL=http://localhost:4000
LOGFLARE_PRIVATE_ACCESS_TOKEN=your-super-secret-and-long-logflare-key-private
# TODO: evaluate these variables at runtime instead
-# https://nextjs.org/docs/basic-features/environment-variables#loading-environment-variables
NEXT_PUBLIC_SITE_URL=http://localhost:3000
NEXT_PUBLIC_GOTRUE_URL=$SUPABASE_PUBLIC_URL/auth/v1
NEXT_PUBLIC_HCAPTCHA_SITE_KEY=10000000-ffff-ffff-ffff-000000000001
diff --git a/apps/studio/.github/eslint-rule-baselines.json b/apps/studio/.github/eslint-rule-baselines.json
index d14ac31e0f9..3dbcdc4c086 100644
--- a/apps/studio/.github/eslint-rule-baselines.json
+++ b/apps/studio/.github/eslint-rule-baselines.json
@@ -118,14 +118,7 @@
"hooks/misc/useSchemaQueryState.ts": 1,
"hooks/misc/useUpgradePrompt.tsx": 1,
"lib/telemetry/track.ts": 1,
- "pages/forgot-password-mfa.tsx": 1,
- "pages/logout.tsx": 1,
"routes/project/$ref/database/policies.tsx": 2,
- "pages/project/[ref]/editor/[id].tsx": 1,
- "pages/project/[ref]/integrations/[id]/index.tsx": 1,
- "pages/project/[ref]/settings/jwt/legacy.tsx": 1,
- "pages/project/[ref]/sql/examples.tsx": 1,
- "pages/project/[ref]/sql/templates.tsx": 1,
"routes/_app/new/index.tsx": 1,
"state/role-impersonation-state.tsx": 1,
"state/sidebar-manager-state.tsx": 1,
@@ -476,18 +469,6 @@
"lib/profile.tsx": 1,
"lib/role-impersonation.ts": 1,
"lib/telemetry/track.ts": 1,
- "pages/_app.tsx": 1,
- "pages/api/ai/feedback/rate.ts": 2,
- "pages/api/check-cname.ts": 1,
- "pages/api/edge-functions/test.ts": 1,
- "pages/api/platform/auth/[ref]/users/[id]/factors.ts": 1,
- "pages/api/platform/database/[ref]/pooling.ts": 1,
- "pages/api/platform/integrations/github/authorization.ts": 1,
- "pages/api/platform/projects/[ref]/analytics/log-drains.ts": 1,
- "pages/api/platform/projects/[ref]/content/count.ts": 1,
- "pages/api/platform/projects/[ref]/content/index.ts": 1,
- "pages/api/platform/projects/[ref]/databases.ts": 1,
- "pages/project/[ref]/settings/log-drains.tsx": 1,
"state/ai-assistant-state.tsx": 4,
"state/sql-editor/sql-editor-session-state.ts": 4,
"state/storage-explorer.tsx": 15,
@@ -495,7 +476,6 @@
"state/table-editor.tsx": 5,
"tests/setup/polyfills.ts": 3,
"tests/vitestSetup.ts": 1,
- "types/next.ts": 2,
"types/ui.ts": 2
},
"no-restricted-exports": {
@@ -666,7 +646,6 @@
"hooks/analytics/useSingleLog.tsx": 1,
"hooks/analytics/useTimeseriesUnixToIso.ts": 1,
"lib/pingPostgrest.ts": 1,
- "pages/_error.jsx": 1,
"scripts/codegen.ts": 1
},
"react/no-unstable-nested-components": {
@@ -811,13 +790,7 @@
"components/ui/Charts/ReportSettings.tsx": 2,
"components/ui/Logs/LogsExplorerHeader.tsx": 1,
"components/ui/PasswordStrengthBar.tsx": 1,
- "components/ui/Resource/ResourceItem.tsx": 1,
- "pages/project/[ref]/auth/templates/[templateId].tsx": 1,
- "pages/project/[ref]/observability/auth.tsx": 1,
- "pages/project/[ref]/observability/edge-functions.tsx": 1,
- "pages/project/[ref]/observability/postgrest.tsx": 1,
- "pages/project/[ref]/observability/realtime.tsx": 1,
- "pages/project/[ref]/observability/storage.tsx": 1
+ "components/ui/Resource/ResourceItem.tsx": 1
},
"jsx-a11y/label-has-associated-control": {
"components/interfaces/Auth/EmailTemplates/TemplateEditor.tsx": 1,
@@ -951,8 +924,6 @@
"components/ui/GlobalShortcuts/ShortcutsReferenceSheet.tsx": 1,
"components/ui/ShortcutBadge.tsx": 1,
"components/ui/ShortcutTooltip.tsx": 1,
- "pages/project/[ref]/settings/infrastructure/replica/[replicaId].tsx": 1,
- "pages/project/[ref]/settings/log-drains.tsx": 2,
"state/shortcuts/useDynamicShortcut.tsx": 1,
"state/shortcuts/useShortcut.tsx": 1
},
@@ -1049,9 +1020,7 @@
"components/ui/Forms/FormSection.tsx": 2,
"components/ui/QueryBlock/QueryBlock.tsx": 3,
"components/ui/ShimmerLine.tsx": 1,
- "components/ui/Shimmers.tsx": 3,
- "pages/project/[ref]/functions/[functionSlug]/code.tsx": 1,
- "pages/project/[ref]/storage/vectors/buckets/[bucketId].tsx": 1
+ "components/ui/Shimmers.tsx": 3
},
"shadcn/no-raw-colors": {
"components/interfaces/Advisors/AdvisorRuleItem.tsx": 1,
@@ -1354,8 +1323,6 @@
"lib/ai/tools/execute-sql.server.ts": 1,
"lib/ai/tools/run-notebook.server.ts": 1,
"lib/ai/tools/tool-sql.server.ts": 1,
- "pages/api/ai/code/complete.ts": 2,
- "pages/api/ai/sql/generate-v4.ts": 1,
"state/role-impersonation-state.tsx": 1
}
}
diff --git a/apps/studio/AGENTS.md b/apps/studio/AGENTS.md
index b5223318cee..a4252c34118 100644
--- a/apps/studio/AGENTS.md
+++ b/apps/studio/AGENTS.md
@@ -24,7 +24,7 @@ Load the skills matching the task; stack them when a task spans areas:
Routes live in `routes/**` (TanStack Start file routes); `routeTree.gen.ts` is generated by the Vite plugin — never hand-edit it.
-- New code uses native TanStack APIs (`Link`, `useNavigate`, `Route.useParams()`, `useSearch`) — no `next/*` imports. Only `next/script` is still shimmed: older components import it and `vite.config.ts` aliases it to `compat/next/`; any other `next/*` import fails the build. Switch a component to native APIs when you touch its routing.
+- Use native TanStack APIs (`Link`, `useNavigate`, `Route.useParams()`, `useSearch`) — no `next/*` imports.
- Layouts are pathless (`routes/_app.tsx`, `routes/_auth.tsx`) or sibling-file shells (`routes/project/$ref/database.tsx` wraps `routes/project/$ref/database/**`), configured per leaf through `staticData`.
- Route files export only `Route`; shared components belong in `components/**`.
diff --git a/apps/studio/compat/next/script.test.tsx b/apps/studio/compat/next/script.test.tsx
deleted file mode 100644
index 31824859de3..00000000000
--- a/apps/studio/compat/next/script.test.tsx
+++ /dev/null
@@ -1,191 +0,0 @@
-import { act, render } from '@testing-library/react'
-import { afterEach, describe, expect, it, vi } from 'vitest'
-
-import Script from './script'
-
-// The shim's load caches are module-level (like Next's), so each test uses
-// its own id/src.
-//
-// jsdom runs scripts against its own window, which vitest's test-side
-// `window` doesn't share, so inline scripts record runs on the shared
-// document instead of a window global.
-const inlineCounter = (key: string) =>
- `var el = document.documentElement; el.dataset['run_${key}'] = String(Number(el.dataset['run_${key}'] || 0) + 1);`
-
-const runs = (key: string) => Number(document.documentElement.dataset[`run_${key}`] ?? 0)
-
-afterEach(() => {
- document.body.querySelectorAll('script[data-nscript]').forEach((el) => el.remove())
-})
-
-describe('next/script compat shim', () => {
- it('executes an inline dangerouslySetInnerHTML script and renders nothing in place', () => {
- const onReady = vi.fn()
- const { container } = render(
-
- )
-
- expect(runs('inlineHtml')).toBe(1)
- expect(onReady).toHaveBeenCalledTimes(1)
- expect(container.innerHTML).toBe('')
-
- const el = document.getElementById('inlineHtml')
- expect(el?.parentElement).toBe(document.body)
- expect(el?.getAttribute('data-nscript')).toBe('afterInteractive')
- })
-
- it('executes an inline script passed as children', () => {
- render()
- expect(runs('inlineChildren')).toBe(1)
- })
-
- it('executes a script with the same id only once across instances and remounts', () => {
- const body = { __html: inlineCounter('dedupe') }
- const first = render(
- <>
-
-
- >
- )
- first.unmount()
- render()
-
- expect(runs('dedupe')).toBe(1)
- expect(document.querySelectorAll('script#dedupe')).toHaveLength(1)
- })
-
- it('appends a src script as a real element and wires onLoad/onReady to its load event', () => {
- const onLoad = vi.fn()
- const onReady = vi.fn()
- render(
-
- )
-
- const el = document.querySelector('script[src="https://example.com/a.js"]')
- expect(el).not.toBeNull()
- expect(el?.parentElement).toBe(document.body)
- expect(el?.getAttribute('crossorigin')).toBe('anonymous')
- expect(el?.getAttribute('data-foo')).toBe('bar')
- expect(onLoad).not.toHaveBeenCalled()
- expect(onReady).not.toHaveBeenCalled()
-
- act(() => {
- el?.dispatchEvent(new Event('load'))
- })
-
- expect(onLoad).toHaveBeenCalledTimes(1)
- expect(onReady).toHaveBeenCalledTimes(1)
- })
-
- it('calls onError when a src script fails to load', async () => {
- const onError = vi.fn()
- render()
-
- const el = document.querySelector('script[src="https://example.com/broken.js"]')
- await act(async () => {
- el?.dispatchEvent(new Event('error'))
- })
-
- expect(onError).toHaveBeenCalledTimes(1)
- })
-
- it('retries a src script on a later mount after it failed to load', async () => {
- const src = 'https://example.com/flaky.js'
- const first = render()
- await act(async () => {
- document.querySelector(`script[src="${src}"]`)?.dispatchEvent(new Event('error'))
- })
- first.unmount()
-
- const onLoad = vi.fn()
- const onReady = vi.fn()
- render()
-
- // Not treated as loaded: no onReady until the retried script loads.
- expect(onReady).not.toHaveBeenCalled()
- const retried = document.querySelectorAll(`script[src="${src}"]`)
- expect(retried).toHaveLength(1)
- act(() => {
- retried[0].dispatchEvent(new Event('load'))
- })
- expect(onLoad).toHaveBeenCalledTimes(1)
- expect(onReady).toHaveBeenCalledTimes(1)
- })
-
- it('runs onLoad, onReady and onError for every instance sharing an in-flight src', async () => {
- const loaded = 'https://example.com/shared.js'
- const firstReady = vi.fn()
- const secondLoad = vi.fn()
- const secondReady = vi.fn()
- render()
- render()
- expect(document.querySelectorAll(`script[src="${loaded}"]`)).toHaveLength(1)
- await act(async () => {
- document.querySelector(`script[src="${loaded}"]`)?.dispatchEvent(new Event('load'))
- })
- expect(firstReady).toHaveBeenCalledTimes(1)
- expect(secondLoad).toHaveBeenCalledTimes(1)
- expect(secondReady).toHaveBeenCalledTimes(1)
-
- const failed = 'https://example.com/shared-broken.js'
- const firstError = vi.fn()
- const secondError = vi.fn()
- render()
- render()
- await act(async () => {
- document.querySelector(`script[src="${failed}"]`)?.dispatchEvent(new Event('error'))
- })
- expect(firstError).toHaveBeenCalledTimes(1)
- expect(secondError).toHaveBeenCalledTimes(1)
- })
-
- it('fires onReady on remount without re-injecting an already loaded script', () => {
- const src = 'https://example.com/b.js'
- const first = render()
- act(() => {
- document.querySelector(`script[src="${src}"]`)?.dispatchEvent(new Event('load'))
- })
- first.unmount()
-
- const onLoad = vi.fn()
- const onReady = vi.fn()
- render()
-
- expect(onReady).toHaveBeenCalledTimes(1)
- expect(onLoad).not.toHaveBeenCalled()
- expect(document.querySelectorAll(`script[src="${src}"]`)).toHaveLength(1)
- })
-
- it('defers lazyOnload scripts until the browser is idle', async () => {
- vi.useFakeTimers()
- try {
- render(
-
- )
- expect(runs('lazy')).toBe(0)
-
- await act(async () => {
- await vi.runAllTimersAsync()
- })
-
- expect(runs('lazy')).toBe(1)
- expect(document.getElementById('lazy')?.getAttribute('data-nscript')).toBe('lazyOnload')
- } finally {
- vi.useRealTimers()
- }
- })
-})
diff --git a/apps/studio/compat/next/script.tsx b/apps/studio/compat/next/script.tsx
deleted file mode 100644
index 7b3720ae6f6..00000000000
--- a/apps/studio/compat/next/script.tsx
+++ /dev/null
@@ -1,181 +0,0 @@
-import { useEffect, useRef, type ComponentPropsWithoutRef, type ReactNode } from 'react'
-
-// Client-only port of next/script (next/dist/client/script.js) for the
-// TanStack build. React never executes