Repository navigation
feat: add mpa mode to file-system routing - #197
Merged
Merged
Conversation
Add an optional `mode` option to `fsRoutes` (and `createFsRoutesEntries`). The default `"spa"` keeps the current behavior: pages render with FUNSTACK Router's `<Router>`, links are followed by soft client-side navigation, and Server Component output is pre-rendered as RSC chunks fetched on navigation. The new `"mpa"` mode renders pages with `<RouteDisplay>` (FUNSTACK Router 1.6), which never intercepts navigations, so every link loads the destination's own HTML. Each page's route definitions cover only its own route chain with Server Component output inlined directly, and no navigation chunks are registered or emitted. Includes unit tests, an e2e fixture with build and dev-server specs, and documentation for the new option. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014ERdZEFjZXcbrh8pQttyc4
Add `example-fs-routing-mpa`, a sibling of `example-fs-routing` configured with `fsRoutes.mode: "mpa"`. It shows that every link loads a new document (client-side state in the shell resets), that `useSearchParams`'s setter performs a full page navigation under `<RouteDisplay>`, and that a dynamic Server Component page needs no route object to show the right params. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014ERdZEFjZXcbrh8pQttyc4
Make `mode` a required field of `fsRoutes`, like `dir`, `root` and
`adapter`, so the choice between soft client-side navigation ("spa") and
full page loads ("mpa") is explicit in every config. The plugin fails with a
clear error when it is missing. `createFsRoutesEntries` keeps its "spa"
default, mirroring how `adapter` is optional there.
File-system routing is experimental, so this is not a semver-breaking
change for the package.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014ERdZEFjZXcbrh8pQttyc4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
File-system routing currently always produces an SPA: pages render with FUNSTACK Router's
<Router>, and link clicks are intercepted for soft client-side navigation. Some users prefer a classic multi-page site without soft navigation. This PR adds a requiredmodefield tofsRouteswith two values:"spa"— the existing behavior."mpa"— pages render with<RouteDisplay>from@funstack/router1.6, which never intercepts navigations, so every link loads the destination's own HTML.modeis required like the otherfsRoutesfields, so the choice is explicit in every config; the plugin fails with a clear error when it is missing. File-system routing is experimental, so existing configs adding the field is within the feature's stability contract. The lower-levelcreateFsRoutesEntrieskeeps a"spa"default, mirroring howadapteris optional there.How MPA mode works
FsRoutesApprenders<RouteDisplay routes ssr={{ path }}>instead of<Router>.paramsandrouteobject; noFsRouteSlotis involved. Client Components are still passed as component types so the router renders them with the matched params.FsRoutesModeis exported from@funstack/static/fs-routes.Tests
fixture-fs-routing-mpafixture with build and dev-server specs (ports 4181/4182). Navigation tests assert a full document replacement by planting a window marker before each click and checking it is gone afterwards; shell client state is also checked to reset. Both the new MPA projects and the existing SPA projects pass in build and dev mode.Docs and example
fsRoutessnippets now includemode.modedocumented in thefunstackStatic()API reference.example-fs-routing-mpapackage showing full page loads on links,useSearchParams's setter performing a full navigation under<RouteDisplay>, and a dynamic Server Component page in MPA mode.Notes for review
feat/fs-routes-mpa-modebranch taking a different approach (JavaScript-free pages via SSR/RSC entry changes). This PR is independent of it.🤖 Generated with Claude Code
https://claude.ai/code/session_014ERdZEFjZXcbrh8pQttyc4