Skip to content

feat: multi-entry SSG for docs site#114

Merged
uhyo merged 2 commits intomasterfrom
multi-entry-ssg
Feb 21, 2026
Merged

feat: multi-entry SSG for docs site#114
uhyo merged 2 commits intomasterfrom
multi-entry-ssg

Conversation

@uhyo
Copy link
Owner

@uhyo uhyo commented Feb 21, 2026

Summary

  • Fix router to provide URL in RouterContext during SSR so useLocation() works with the ssr prop
  • Switch docs site from single-entry SPA to multi-entry SSG, generating one HTML file per route
  • Each route gets pre-rendered HTML, improving initial load performance and SEO

Changes

Router (@funstack/router)

  • RouterContext.url now falls back to new URL(ssr.path, "http://localhost") when the ssr prop is provided, instead of always being null
  • Added test verifying useLocation() works during SSR

Docs site

  • Added ssrPath prop to App and ClientApp, passed through as ssr={{ path: ssrPath }} to <Router>
  • Created entries.tsx that derives entries from the route tree automatically — adding a route to App.tsx automatically generates a new HTML entry
  • Switched vite.config.ts from single-entry (root/app) to multi-entry (entries) mode with SSR enabled
  • Changed Cloudflare not_found_handling from single-page-application to 404-page
  • Added urlpattern-polyfill for Vite's SSR dev server (runs in an isolated VM context without Node.js globals)

Test plan

  • pnpm --filter @funstack/router test:run — 227 tests pass
  • pnpm build — all packages build, 18 HTML files generated
  • pnpm typecheck — all packages pass
  • Dev server renders pages correctly

🤖 Generated with Claude Code

uhyo and others added 2 commits February 21, 2026 14:42
useLocation() threw during SSR because RouterContext.url was always null
when there was no locationEntry. Now falls back to constructing a URL
from ssr.path, consistent with how route matching already works.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Generate one HTML file per route instead of relying on SPA fallback.
Each route gets pre-rendered HTML, improving initial load and SEO.

- Add entries.tsx that derives entry list from the route tree
- Pass ssrPath through App → ClientApp → Router
- Switch vite.config.ts from single-entry to multi-entry mode
- Change Cloudflare not_found_handling to 404-page

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@uhyo uhyo merged commit 123819b into master Feb 21, 2026
1 check passed
@uhyo uhyo deleted the multi-entry-ssg branch February 21, 2026 05:59
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