Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .claude/skills/funstack-router-knowledge/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: funstack-router-knowledge
description: Use this skill when you need information about `@funstack/router` (the React router your app uses). What it is, API references, best practices, etc.
metadata:
internal: true
---

# FUNSTACK Router Knowledge

**FUNSTACK Router** (`@funstack/router`) is a modern React router built on the [Navigation API](https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API) (not the History API). It uses the [URLPattern API](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) for path matching.

## Entrypoints

- `@funstack/router` — Main entrypoint. Provides `Router`, `Outlet`, hooks (`useNavigate`, `useRouteParams`, etc.), and route definition utilities (`route()`, `routeState()`).
- `@funstack/router/server` — Entrypoint for Server context when you are using React Server Components. Provides `route()` and `routeState()` utilities for defining routes in server modules.

## FUNSTACK Router Docs

More detailed documentation (including API references and best practices) can be found at:

```
node_modules/@funstack/router/dist/docs/index.md
```
5 changes: 3 additions & 2 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@funstack/router": "0.0.7",
"@funstack/router": "^0.0.9",
"@funstack/static": "workspace:*",
"@shikijs/rehype": "^3.22.0",
"@types/node": "catalog:",
"react": "catalog:",
"react-dom": "catalog:",
"rehype-slug": "^6.0.0",
"shiki": "^3.22.0"
"shiki": "^3.22.0",
"urlpattern-polyfill": "^10.1.0"
},
"devDependencies": {
"@mdx-js/rollup": "^3.1.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/docs/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Home } from "./pages/Home";
import { NotFound } from "./pages/NotFound";
import { Router } from "./Router";

const routes: RouteDefinition[] = [
export const routes: RouteDefinition[] = [
route({
path: import.meta.env.BASE_URL.replace(/\/$/, ""),
component: <Outlet />,
Expand Down Expand Up @@ -132,6 +132,6 @@ const routes: RouteDefinition[] = [
}),
];

export default function App() {
return <Router routes={routes} fallback="static" />;
export default function App({ ssrPath }: { ssrPath: string }) {
return <Router routes={routes} fallback="static" ssr={{ path: ssrPath }} />;
}
29 changes: 29 additions & 0 deletions packages/docs/src/entries.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import "urlpattern-polyfill";
import type { EntryDefinition } from "@funstack/static/entries";
import type { RouteDefinition } from "@funstack/router/server";
import App, { routes } from "./App";

function collectPaths(routes: RouteDefinition[]): string[] {
const paths: string[] = [];
for (const route of routes) {
if (route.children) {
paths.push(...collectPaths(route.children));
} else if (route.path !== undefined && route.path !== "*") {
paths.push(route.path);
}
}
return paths;
}

function pathToEntryPath(path: string): string {
if (path === "/") return "index.html";
return `${path.slice(1)}/index.html`;
}

export default function getEntries(): EntryDefinition[] {
return collectPaths(routes).map((pathname) => ({
path: pathToEntryPath(pathname),
root: () => import("./root"),
app: <App ssrPath={pathname} />,
}));
}
4 changes: 2 additions & 2 deletions packages/docs/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default defineConfig(async () => {
const config: UserConfig = {
plugins: [
funstackStatic({
root: "./src/root.tsx",
app: "./src/App.tsx",
entries: "./src/entries.tsx",
ssr: true,
}),
{
// to make .mdx loading lazy
Expand Down
18 changes: 13 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.