Skip to content

Add relative path prefix support to routeFor utilities#3292

Draft
Alex-Tideman wants to merge 2 commits intomainfrom
relative-paths
Draft

Add relative path prefix support to routeFor utilities#3292
Alex-Tideman wants to merge 2 commits intomainfrom
relative-paths

Conversation

@Alex-Tideman
Copy link
Copy Markdown
Collaborator

@Alex-Tideman Alex-Tideman commented Apr 10, 2026

Summary

  • Adds a routePrefix mechanism via CoreProvider that allows consuming projects (e.g., Temporal Cloud) to inject a path prefix into all UI route functions
  • Introduces a withPrefix helper that inserts the prefix between the SvelteKit base path and the route path across the 12 root resolve() calls — leaf functions inherit the prefix automatically through existing string concatenation
  • Auth routes (routeForAuthentication, routeForLoginPage) are explicitly excluded to avoid breaking SSO flows
  • Moves getRoutePrefix to CoreProvider so the prefix is available globally and configured at initialization

Changes

  • core-provider.ts: Added getRoutePrefix to the CoreProvider type and InitOptions, with a default no-op returning ''
  • route-for.ts: Added withPrefix() helper wrapping all root route functions; auth routes left unwrapped
  • hooks.client.ts: OSS init passes getRoutePrefix: () => '' to maintain current behavior
  • route-for.test.ts: Added test suite verifying prefix propagation through root, namespace, workflow, nexus, and schedule routes, plus exclusion from auth routes
  • route-for-base-path.test.ts: Added comprehensive parameterized tests covering all routeFor functions with prefix enabled, ensuring base + prefix appears exactly once and auth routes remain prefix-free

Test plan

  • pnpm test -- --run passes all new and existing route-for tests
  • Verify OSS app behavior is unchanged (prefix defaults to empty string)
  • Verify consuming project can set a prefix and all navigation routes include it
  • Verify auth/login routes do not include the prefix

Introduce a routePrefix store that allows consuming projects to inject
a path prefix (e.g., /projects/{projectId}) into all UI route functions.
The prefix is inserted between the SvelteKit base path and the route
path via a withPrefix helper that wraps the 12 root resolve() calls.
Leaf functions inherit the prefix automatically through the existing
string concatenation chain. Auth routes are excluded to avoid breaking
SSO flows.
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
holocene Ready Ready Preview, Comment Apr 10, 2026 5:13pm

Request Review

@Alex-Tideman Alex-Tideman marked this pull request as ready for review April 10, 2026 17:19
@Alex-Tideman Alex-Tideman requested a review from a team as a code owner April 10, 2026 17:19
@Alex-Tideman Alex-Tideman marked this pull request as draft April 10, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant