create-rango 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +348 -0
- package/package.json +50 -0
- package/templates/basic/.oxfmtrc.json +9 -0
- package/templates/basic/.oxlintrc.json +6 -0
- package/templates/basic/README.md +35 -0
- package/templates/basic/_gitignore +4 -0
- package/templates/basic/package.json +44 -0
- package/templates/basic/server.mjs +46 -0
- package/templates/basic/src/actions/counter.ts +11 -0
- package/templates/basic/src/components/Counter.tsx +50 -0
- package/templates/basic/src/components/Document.tsx +78 -0
- package/templates/basic/src/components/Fallbacks.tsx +36 -0
- package/templates/basic/src/components/pages/AboutPage.tsx +21 -0
- package/templates/basic/src/components/pages/CounterPage.tsx +27 -0
- package/templates/basic/src/components/pages/GreetingPage.tsx +24 -0
- package/templates/basic/src/components/pages/HomePage.tsx +52 -0
- package/templates/basic/src/data/counter.ts +11 -0
- package/templates/basic/src/router.gen.ts +8 -0
- package/templates/basic/src/router.named-routes.gen.ts +17 -0
- package/templates/basic/src/router.tsx +33 -0
- package/templates/basic/src/styles.css +5 -0
- package/templates/basic/test/router.test.ts +8 -0
- package/templates/basic/tsconfig.json +19 -0
- package/templates/basic/vite.config.ts +17 -0
- package/templates/basic/vitest.config.ts +10 -0
- package/templates/basic-js/.oxfmtrc.json +9 -0
- package/templates/basic-js/.oxlintrc.json +6 -0
- package/templates/basic-js/README.md +38 -0
- package/templates/basic-js/_gitignore +4 -0
- package/templates/basic-js/package.json +40 -0
- package/templates/basic-js/server.mjs +46 -0
- package/templates/basic-js/src/actions/counter.js +11 -0
- package/templates/basic-js/src/components/Counter.jsx +50 -0
- package/templates/basic-js/src/components/Document.jsx +78 -0
- package/templates/basic-js/src/components/Fallbacks.jsx +36 -0
- package/templates/basic-js/src/components/pages/AboutPage.jsx +21 -0
- package/templates/basic-js/src/components/pages/CounterPage.jsx +27 -0
- package/templates/basic-js/src/components/pages/GreetingPage.jsx +24 -0
- package/templates/basic-js/src/components/pages/HomePage.jsx +52 -0
- package/templates/basic-js/src/data/counter.js +11 -0
- package/templates/basic-js/src/router.gen.ts +8 -0
- package/templates/basic-js/src/router.jsx +25 -0
- package/templates/basic-js/src/router.named-routes.gen.ts +17 -0
- package/templates/basic-js/src/styles.css +5 -0
- package/templates/basic-js/test/router.test.js +8 -0
- package/templates/basic-js/vite.config.js +17 -0
- package/templates/basic-js/vitest.config.js +10 -0
- package/templates/cloudflare/.oxfmtrc.json +9 -0
- package/templates/cloudflare/.oxlintrc.json +6 -0
- package/templates/cloudflare/README.md +40 -0
- package/templates/cloudflare/_gitignore +6 -0
- package/templates/cloudflare/package.json +44 -0
- package/templates/cloudflare/src/actions/counter.ts +11 -0
- package/templates/cloudflare/src/components/Counter.tsx +50 -0
- package/templates/cloudflare/src/components/Document.tsx +78 -0
- package/templates/cloudflare/src/components/Fallbacks.tsx +36 -0
- package/templates/cloudflare/src/components/pages/AboutPage.tsx +21 -0
- package/templates/cloudflare/src/components/pages/CounterPage.tsx +27 -0
- package/templates/cloudflare/src/components/pages/GreetingPage.tsx +24 -0
- package/templates/cloudflare/src/components/pages/HomePage.tsx +52 -0
- package/templates/cloudflare/src/data/counter.ts +11 -0
- package/templates/cloudflare/src/env.ts +13 -0
- package/templates/cloudflare/src/router.gen.ts +8 -0
- package/templates/cloudflare/src/router.named-routes.gen.ts +17 -0
- package/templates/cloudflare/src/router.tsx +33 -0
- package/templates/cloudflare/src/styles.css +5 -0
- package/templates/cloudflare/src/worker.rsc.tsx +9 -0
- package/templates/cloudflare/test/router.test.ts +8 -0
- package/templates/cloudflare/tsconfig.json +19 -0
- package/templates/cloudflare/vite.config.ts +17 -0
- package/templates/cloudflare/vitest.config.ts +10 -0
- package/templates/cloudflare/wrangler.json +9 -0
- package/templates/vercel/.oxfmtrc.json +9 -0
- package/templates/vercel/.oxlintrc.json +6 -0
- package/templates/vercel/README.md +50 -0
- package/templates/vercel/_gitignore +5 -0
- package/templates/vercel/package.json +43 -0
- package/templates/vercel/scripts/preview.mjs +23 -0
- package/templates/vercel/scripts/serve-vercel-output.mjs +67 -0
- package/templates/vercel/src/actions/counter.ts +11 -0
- package/templates/vercel/src/components/Counter.tsx +50 -0
- package/templates/vercel/src/components/Document.tsx +78 -0
- package/templates/vercel/src/components/Fallbacks.tsx +36 -0
- package/templates/vercel/src/components/pages/AboutPage.tsx +21 -0
- package/templates/vercel/src/components/pages/CounterPage.tsx +27 -0
- package/templates/vercel/src/components/pages/GreetingPage.tsx +24 -0
- package/templates/vercel/src/components/pages/HomePage.tsx +52 -0
- package/templates/vercel/src/data/counter.ts +11 -0
- package/templates/vercel/src/router.gen.ts +8 -0
- package/templates/vercel/src/router.named-routes.gen.ts +17 -0
- package/templates/vercel/src/router.tsx +33 -0
- package/templates/vercel/src/styles.css +5 -0
- package/templates/vercel/test/router.test.ts +8 -0
- package/templates/vercel/tsconfig.json +19 -0
- package/templates/vercel/vite.config.ts +17 -0
- package/templates/vercel/vitest.config.ts +10 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Meta, type HandlerContext } from "@rangojs/router";
|
|
2
|
+
import { Link } from "@rangojs/router/client";
|
|
3
|
+
|
|
4
|
+
export function HomePage(ctx: HandlerContext) {
|
|
5
|
+
const meta = ctx.use(Meta);
|
|
6
|
+
meta({ title: "Home — Rango" });
|
|
7
|
+
meta({
|
|
8
|
+
name: "description",
|
|
9
|
+
content: "A React Server Components app powered by @rangojs/router",
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const greetingUrl = ctx.reverse("greeting", { name: "world" });
|
|
13
|
+
const counterUrl = ctx.reverse("counter");
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<main>
|
|
17
|
+
<h1 className="text-3xl font-semibold tracking-tight">
|
|
18
|
+
Welcome to Rango
|
|
19
|
+
</h1>
|
|
20
|
+
<p className="mt-4 leading-7 text-zinc-600 dark:text-zinc-400">
|
|
21
|
+
This starter renders React Server Components with streaming SSR, typed
|
|
22
|
+
routes, and Tailwind CSS. Handlers run on the server; client components
|
|
23
|
+
hydrate where you opt in with <code>"use client"</code>.
|
|
24
|
+
</p>
|
|
25
|
+
<ul className="mt-8 space-y-3">
|
|
26
|
+
<li className="rounded-lg border border-zinc-200 p-4 dark:border-zinc-800">
|
|
27
|
+
<Link
|
|
28
|
+
to={greetingUrl}
|
|
29
|
+
className="font-medium text-blue-600 hover:underline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-blue-600 dark:text-blue-400 dark:focus-visible:outline-blue-400"
|
|
30
|
+
>
|
|
31
|
+
Dynamic route
|
|
32
|
+
</Link>
|
|
33
|
+
<p className="mt-1 text-sm text-zinc-600 dark:text-zinc-400">
|
|
34
|
+
<code>/hello/:name</code> — read path params from the handler
|
|
35
|
+
context.
|
|
36
|
+
</p>
|
|
37
|
+
</li>
|
|
38
|
+
<li className="rounded-lg border border-zinc-200 p-4 dark:border-zinc-800">
|
|
39
|
+
<Link
|
|
40
|
+
to={counterUrl}
|
|
41
|
+
className="font-medium text-blue-600 hover:underline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-blue-600 dark:text-blue-400 dark:focus-visible:outline-blue-400"
|
|
42
|
+
>
|
|
43
|
+
Server actions
|
|
44
|
+
</Link>
|
|
45
|
+
<p className="mt-1 text-sm text-zinc-600 dark:text-zinc-400">
|
|
46
|
+
A client component calling <code>"use server"</code> functions.
|
|
47
|
+
</p>
|
|
48
|
+
</li>
|
|
49
|
+
</ul>
|
|
50
|
+
</main>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// In-memory state for demo purposes: it resets on restart and is per-instance.
|
|
2
|
+
// Use a database or KV store in a real app.
|
|
3
|
+
let count = 0;
|
|
4
|
+
|
|
5
|
+
export function getCount(): number {
|
|
6
|
+
return count;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function updateCount(delta: number): void {
|
|
10
|
+
count += delta;
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Auto-generated by @rangojs/router - do not edit
|
|
2
|
+
export const NamedRoutes = {
|
|
3
|
+
about: "/about",
|
|
4
|
+
counter: "/counter",
|
|
5
|
+
greeting: "/hello/:name",
|
|
6
|
+
home: "/",
|
|
7
|
+
} as const;
|
|
8
|
+
|
|
9
|
+
// Aliased so the augmentation below does not pay a homomorphic mapped-type
|
|
10
|
+
// instantiation per route; `as const` already makes the members readonly.
|
|
11
|
+
type NamedRoutesShape = typeof NamedRoutes;
|
|
12
|
+
|
|
13
|
+
declare global {
|
|
14
|
+
namespace Rango {
|
|
15
|
+
interface GeneratedRouteMap extends NamedRoutesShape {}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createRouter, urls } from "@rangojs/router";
|
|
2
|
+
import { updateCount } from "./actions/counter.js";
|
|
3
|
+
import { Document } from "./components/Document.js";
|
|
4
|
+
import { ErrorFallback, NotFoundPage } from "./components/Fallbacks.js";
|
|
5
|
+
import { HomePage } from "./components/pages/HomePage.js";
|
|
6
|
+
import { AboutPage } from "./components/pages/AboutPage.js";
|
|
7
|
+
import { GreetingPage } from "./components/pages/GreetingPage.js";
|
|
8
|
+
import { CounterPage } from "./components/pages/CounterPage.js";
|
|
9
|
+
|
|
10
|
+
export const urlpatterns = urls(({ path, revalidate }) => [
|
|
11
|
+
path("/", HomePage, { name: "home" }),
|
|
12
|
+
path("/about", AboutPage, { name: "about" }),
|
|
13
|
+
path("/hello/:name", GreetingPage, { name: "greeting" }),
|
|
14
|
+
path("/counter", CounterPage, { name: "counter" }, () => [
|
|
15
|
+
revalidate((ctx) => ctx.isAction(updateCount) || undefined),
|
|
16
|
+
]),
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
export const router = createRouter({
|
|
20
|
+
document: Document,
|
|
21
|
+
urls: urlpatterns,
|
|
22
|
+
defaultErrorBoundary: ErrorFallback,
|
|
23
|
+
defaultNotFoundBoundary: NotFoundPage,
|
|
24
|
+
notFound: NotFoundPage,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
type AppRoutes = typeof router.routeMap;
|
|
28
|
+
|
|
29
|
+
declare global {
|
|
30
|
+
namespace Rango {
|
|
31
|
+
interface RegisteredRoutes extends AppRoutes {}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { assertGeneratedRoutesMatch } from "@rangojs/router/testing";
|
|
2
|
+
import { test } from "vitest";
|
|
3
|
+
import { NamedRoutes } from "../src/router.named-routes.gen.js";
|
|
4
|
+
import { router } from "../src/router.js";
|
|
5
|
+
|
|
6
|
+
test("generated routes match the runtime router", async () => {
|
|
7
|
+
await assertGeneratedRoutesMatch(router, NamedRoutes);
|
|
8
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2023", "DOM", "DOM.Iterable"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"moduleDetection": "force",
|
|
8
|
+
"allowImportingTsExtensions": true,
|
|
9
|
+
"isolatedModules": true,
|
|
10
|
+
"noEmit": true,
|
|
11
|
+
"jsx": "react-jsx",
|
|
12
|
+
"strict": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"noFallthroughCasesInSwitch": true,
|
|
15
|
+
"noUncheckedSideEffectImports": true,
|
|
16
|
+
"types": ["node", "vite/client"]
|
|
17
|
+
},
|
|
18
|
+
"include": ["src", "vite.config.ts"]
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
4
|
+
import { rango } from "@rangojs/router/vite";
|
|
5
|
+
|
|
6
|
+
// The vercel preset builds like the node preset (Vercel runs Node Functions),
|
|
7
|
+
// folds NODE_ENV for the SSR/RSC build, and assembles .vercel/output
|
|
8
|
+
// (Build Output API v3) from dist/ after `vite build`.
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
plugins: [
|
|
11
|
+
react(),
|
|
12
|
+
tailwindcss(),
|
|
13
|
+
// runtime: the preset default is still nodejs22.x; this app targets
|
|
14
|
+
// Node 24 (see package.json engines), so pin the function runtime to match.
|
|
15
|
+
rango({ preset: "vercel", vercel: { runtime: "nodejs24.x" } }),
|
|
16
|
+
],
|
|
17
|
+
});
|