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
2 changes: 1 addition & 1 deletion create-pages/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"react": "~19.3.0",
"react-dom": "~19.3.0",
"react-server-dom-webpack": "~19.3.0",
"waku": "1.0.0-rc.2"
"waku": "1.0.0-rc.3"
},
"devDependencies": {
"@types/react": "^19.3.0",
Expand Down
2 changes: 1 addition & 1 deletion create-pages/react-tweet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"react-dom": "~19.3.0",
"react-server-dom-webpack": "~19.3.0",
"react-tweet": "^3.3.1",
"waku": "1.0.0-rc.2"
"waku": "1.0.0-rc.3"
},
"devDependencies": {
"@tailwindcss/vite": "4.3.3",
Expand Down
2 changes: 1 addition & 1 deletion create-pages/view-transitions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"react": "~19.3.0",
"react-dom": "~19.3.0",
"react-server-dom-webpack": "~19.3.0",
"waku": "1.0.0-rc.2"
"waku": "1.0.0-rc.3"
},
"devDependencies": {
"@types/react": "^19.3.0",
Expand Down
2 changes: 1 addition & 1 deletion create-pages/weave-render/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"react": "~19.3.0",
"react-dom": "~19.3.0",
"react-server-dom-webpack": "~19.3.0",
"waku": "1.0.0-rc.2"
"waku": "1.0.0-rc.3"
},
"devDependencies": {
"@types/react": "^19.3.0",
Expand Down
2 changes: 1 addition & 1 deletion define-router/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"react": "~19.3.0",
"react-dom": "~19.3.0",
"react-server-dom-webpack": "~19.3.0",
"waku": "1.0.0-rc.2"
"waku": "1.0.0-rc.3"
},
"devDependencies": {
"@types/react": "^19.3.0",
Expand Down
222 changes: 67 additions & 155 deletions define-router/basic/src/waku.server.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { readFile } from 'node:fs/promises';
import type { ReactNode } from 'react';
import adapter from 'waku/adapters/default';
import {
Children_UNSTABLE as Children,
Expand All @@ -12,142 +13,36 @@ import HomePage from './components/HomePage';
import NestedBazPage from './components/NestedBazPage';
import Root from './components/Root';

const renderRoot = () => (
<Root>
<Children />
</Root>
);
const STATIC_PAGES: Record<string, ReactNode> = {
'/': <HomePage />,
'/foo': <FooPage />,
'/bar': <BarPage />,
'/nested/baz': <NestedBazPage />,
};

const renderHomeLayout = () => (
<HomeLayout>
<Children />
</HomeLayout>
);
const root = {
immutable: true,
render: () => (
<Root>
<Children />
</Root>
),
};

const homeLayout = {
immutable: true,
render: () => (
<HomeLayout>
<Children />
</HomeLayout>
),
};

export default adapter(
defineRouter({
getConfigs: async () => [
{
type: 'route',
pattern: '/',
path: [],
isStatic: true,
slices: [],
rootElement: { isStatic: true, renderer: renderRoot },
routeElement: {
isStatic: true,
renderer: () => (
<Slot id="layout:/">
<Slot id="page:/" />
</Slot>
),
},
elements: {
'layout:/': { isStatic: true, renderer: renderHomeLayout },
'page:/': { isStatic: true, renderer: () => <HomePage /> },
},
},
{
type: 'route',
pattern: '/foo',
path: [{ type: 'literal', name: 'foo' }],
isStatic: true,
slices: [],
rootElement: { isStatic: true, renderer: renderRoot },
routeElement: {
isStatic: true,
renderer: () => (
<Slot id="layout:/">
<Slot id="page:/foo" />
</Slot>
),
},
elements: {
'layout:/': { isStatic: true, renderer: renderHomeLayout },
'page:/foo': { isStatic: true, renderer: () => <FooPage /> },
},
},
{
type: 'route',
pattern: '/bar',
path: [{ type: 'literal', name: 'bar' }],
isStatic: true,
slices: [],
rootElement: { isStatic: true, renderer: renderRoot },
routeElement: {
isStatic: true,
renderer: () => (
<Slot id="layout:/">
<Slot id="page:/bar" />
</Slot>
),
},
elements: {
'layout:/': { isStatic: true, renderer: renderHomeLayout },
'page:/bar': { isStatic: true, renderer: () => <BarPage /> },
},
},
{
type: 'route',
pattern: '/nested/baz',
path: [
{ type: 'literal', name: 'nested' },
{ type: 'literal', name: 'baz' },
],
isStatic: true,
slices: [],
rootElement: { isStatic: true, renderer: renderRoot },
routeElement: {
isStatic: true,
renderer: () => (
<Slot id="layout:/">
<Slot id="page:/nested/baz" />
</Slot>
),
},
elements: {
'layout:/': { isStatic: true, renderer: renderHomeLayout },
'page:/nested/baz': {
isStatic: true,
renderer: () => <NestedBazPage />,
},
},
},
{
type: 'route',
pattern: '/dynamic/([^/]+)',
path: [
{ type: 'literal', name: 'dynamic' },
{ type: 'group', name: 'slug' },
],
isStatic: true,
slices: [],
rootElement: { isStatic: true, renderer: renderRoot },
routeElement: {
isStatic: true,
renderer: () => (
<Slot id="layout:/">
<Slot id="page:/dynamic/[slug]" />
</Slot>
),
},
elements: {
'layout:/': { isStatic: true, renderer: renderHomeLayout },
// using `[slug]` syntax is just an example and it technically conflicts with others. So, it's better to use a different prefix like `dynamic-page:`.
'page:/dynamic/[slug]': {
isStatic: false,
renderer: ({ routePath }) => <h3>{routePath}</h3>,
},
},
},
{
type: 'api',
path: [
{ type: 'literal', name: 'api' },
{ type: 'literal', name: 'hi' },
],
isStatic: false,
handler: async () => {
resolve: async (pathname) => {
if (pathname === '/api/hi') {
return async () => {
return new Response(
new ReadableStream({
start(controller) {
Expand All @@ -156,16 +51,10 @@ export default adapter(
},
}),
);
},
},
{
type: 'api',
path: [
{ type: 'literal', name: 'api' },
{ type: 'literal', name: 'hi.txt' },
],
isStatic: true,
handler: async () => {
};
}
if (pathname === '/api/hi.txt') {
return async () => {
const hiTxt = await readFile('./private/hi.txt');
return new Response(
new ReadableStream({
Expand All @@ -175,21 +64,44 @@ export default adapter(
},
}),
);
},
},
{
type: 'api',
path: [
{ type: 'literal', name: 'api' },
{ type: 'literal', name: 'empty' },
],
isStatic: false,
handler: async () => {
};
}
if (pathname === '/api/empty') {
return async () => {
return new Response(null, {
status: 200,
});
},
},
],
};
}
if (pathname in STATIC_PAGES) {
return {
elements: {
root,
route: {
immutable: true,
render: () => <Slot id="layout:/">{STATIC_PAGES[pathname]}</Slot>,
},
'layout:/': homeLayout,
},
};
}
if (/^\/dynamic\/[^/]+$/.test(pathname)) {
return {
elements: {
root,
route: {
render: () => (
<Slot id="layout:/">
<h3>{pathname}</h3>
</Slot>
),
},
'layout:/': homeLayout,
},
};
}
return null;
},
getBuildPaths: async () => [...Object.keys(STATIC_PAGES), '/api/hi.txt'],
}),
);
2 changes: 1 addition & 1 deletion fs-router/basic-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"react": "~19.3.0",
"react-dom": "~19.3.0",
"react-server-dom-webpack": "~19.3.0",
"waku": "1.0.0-rc.2"
"waku": "1.0.0-rc.3"
},
"devDependencies": {
"@rolldown/plugin-babel": "^0.2.4",
Expand Down
2 changes: 1 addition & 1 deletion fs-router/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"react": "~19.3.0",
"react-dom": "~19.3.0",
"react-server-dom-webpack": "~19.3.0",
"waku": "1.0.0-rc.2"
"waku": "1.0.0-rc.3"
},
"devDependencies": {
"@rolldown/plugin-babel": "^0.2.4",
Expand Down
2 changes: 1 addition & 1 deletion fs-router/cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"react": "~19.3.0",
"react-dom": "~19.3.0",
"react-server-dom-webpack": "~19.3.0",
"waku": "1.0.0-rc.2",
"waku": "1.0.0-rc.3",
"wrangler": "^4.141.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion fs-router/css-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"react": "~19.3.0",
"react-dom": "~19.3.0",
"react-server-dom-webpack": "~19.3.0",
"waku": "1.0.0-rc.2"
"waku": "1.0.0-rc.3"
},
"devDependencies": {
"@rolldown/plugin-babel": "^0.2.4",
Expand Down
2 changes: 1 addition & 1 deletion fs-router/data-fetching/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"react": "~19.3.0",
"react-dom": "~19.3.0",
"react-server-dom-webpack": "~19.3.0",
"waku": "1.0.0-rc.2"
"waku": "1.0.0-rc.3"
},
"devDependencies": {
"@rolldown/plugin-babel": "^0.2.4",
Expand Down
2 changes: 1 addition & 1 deletion fs-router/features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"react": "~19.3.0",
"react-dom": "~19.3.0",
"react-server-dom-webpack": "~19.3.0",
"waku": "1.0.0-rc.2"
"waku": "1.0.0-rc.3"
},
"devDependencies": {
"@types/react": "^19.3.0",
Expand Down
2 changes: 1 addition & 1 deletion fs-router/form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"react": "~19.3.0",
"react-dom": "~19.3.0",
"react-server-dom-webpack": "~19.3.0",
"waku": "1.0.0-rc.2"
"waku": "1.0.0-rc.3"
},
"devDependencies": {
"@rolldown/plugin-babel": "^0.2.4",
Expand Down
2 changes: 1 addition & 1 deletion fs-router/jotai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"react": "~19.3.0",
"react-dom": "~19.3.0",
"react-server-dom-webpack": "~19.3.0",
"waku": "1.0.0-rc.2",
"waku": "1.0.0-rc.3",
"waku-jotai": "^0.7.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion fs-router/nextjs-blog-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"react-server-dom-webpack": "~19.3.0",
"remark": "^15.0.1",
"remark-html": "^16.0.1",
"waku": "1.0.0-rc.2"
"waku": "1.0.0-rc.3"
},
"devDependencies": {
"@types/react": "^19.3.0",
Expand Down
2 changes: 1 addition & 1 deletion fs-router/nextjs-commerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"react-server-dom-webpack": "~19.3.0",
"satori": "^0.33.5",
"sonner": "^2.0.8",
"waku": "1.0.0-rc.2"
"waku": "1.0.0-rc.3"
},
"devDependencies": {
"@tailwindcss/container-queries": "^0.1.1",
Expand Down
2 changes: 1 addition & 1 deletion fs-router/nextjs-dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"react-error-boundary": "^6.0.0",
"react-server-dom-webpack": "~19.3.0",
"use-debounce": "^10.0.4",
"waku": "1.0.0-rc.2",
"waku": "1.0.0-rc.3",
"zod": "^3.25.17"
},
"devDependencies": {
Expand Down
Loading
Loading