create-thexjs-app 1.0.0 → 1.1.1
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/README.md +56 -915
- package/dist/index.js +283 -196
- package/package.json +5 -1
- package/templates/{basic → addons/auth}/src/api/auth/login.ts +1 -3
- package/templates/{basic → addons/auth}/src/lib/auth.ts +13 -9
- package/templates/{basic → addons/auth}/src/lib/migrations/001_create_sessions.sql +1 -3
- package/templates/addons/auth/src/pages/dashboard/index.tsx +39 -0
- package/templates/addons/auth/src/pages/login.tsx +72 -0
- package/templates/addons/content/content/hello-world.md +13 -0
- package/templates/addons/content/src/pages/blog.tsx +29 -0
- package/templates/{basic → addons/shadcn}/components.json +1 -1
- package/templates/addons/shadcn/src/components/ui/badge.tsx +17 -0
- package/templates/addons/shadcn/src/components/ui/button.tsx +36 -0
- package/templates/addons/shadcn/src/components/ui/card.tsx +33 -0
- package/templates/addons/shadcn/src/components/ui/input.tsx +18 -0
- package/templates/addons/tailwind/src/styles/globals.css +32 -0
- package/templates/base/_gitignore +26 -0
- package/templates/base/src/pages/index.tsx +29 -0
- package/templates/base/src/styles/globals.css +22 -0
- package/templates/base/tsconfig.json +24 -0
- package/templates/basic/content/blog/hello.md +0 -8
- package/templates/basic/public/favicon.ico +0 -0
- package/templates/basic/src/actions/dashboard/greet.ts +0 -3
- package/templates/basic/src/api/placeholder/comments.ts +0 -17
- package/templates/basic/src/api/placeholder/posts.ts +0 -20
- package/templates/basic/src/api/placeholder/todos.ts +0 -21
- package/templates/basic/src/api/placeholder/users.ts +0 -12
- package/templates/basic/src/components/Head.tsx +0 -21
- package/templates/basic/src/components/Image.tsx +0 -27
- package/templates/basic/src/components/Link.tsx +0 -10
- package/templates/basic/src/components/ui/badge.tsx +0 -49
- package/templates/basic/src/components/ui/button.tsx +0 -58
- package/templates/basic/src/components/ui/card.tsx +0 -88
- package/templates/basic/src/components/ui/input.tsx +0 -20
- package/templates/basic/src/layouts/main.tsx +0 -38
- package/templates/basic/src/lib/placeholder-data.ts +0 -176
- package/templates/basic/src/pages/_404.tsx +0 -17
- package/templates/basic/src/pages/about.tsx +0 -22
- package/templates/basic/src/pages/blog.tsx +0 -41
- package/templates/basic/src/pages/dashboard/index.tsx +0 -84
- package/templates/basic/src/pages/index.tsx +0 -54
- package/templates/basic/src/pages/login.tsx +0 -92
- package/templates/basic/src/pages/placeholder.tsx +0 -203
- package/templates/basic/src/pages/posts/[id].tsx +0 -17
- package/templates/basic/src/styles/globals.css +0 -90
- package/templates/basic/src/x-routes.ts +0 -29
- package/templates/basic/tsconfig.json +0 -11
- package/templates/basic/x.config.ts +0 -10
- package/templates/blog/components.json +0 -20
- package/templates/blog/content/posts/getting-started.md +0 -38
- package/templates/blog/content/posts/hello-world.md +0 -21
- package/templates/blog/content/posts/tailwind-v4.md +0 -31
- package/templates/blog/public/favicon.ico +0 -0
- package/templates/blog/src/components/ui/avatar.tsx +0 -91
- package/templates/blog/src/components/ui/badge.tsx +0 -49
- package/templates/blog/src/components/ui/button.tsx +0 -58
- package/templates/blog/src/components/ui/card.tsx +0 -88
- package/templates/blog/src/components/ui/input.tsx +0 -20
- package/templates/blog/src/layouts/blog.tsx +0 -46
- package/templates/blog/src/layouts/main.tsx +0 -32
- package/templates/blog/src/lib/utils.ts +0 -5
- package/templates/blog/src/pages/about.tsx +0 -36
- package/templates/blog/src/pages/blog/[slug].tsx +0 -56
- package/templates/blog/src/pages/blog/index.tsx +0 -70
- package/templates/blog/src/pages/index.tsx +0 -73
- package/templates/blog/src/styles/globals.css +0 -90
- package/templates/blog/src/x-routes.ts +0 -20
- package/templates/blog/tsconfig.json +0 -5
- package/templates/blog/x.config.ts +0 -6
- package/templates/default/components.json +0 -19
- package/templates/default/src/layouts/main.tsx +0 -28
- package/templates/default/src/pages/index.tsx +0 -66
- package/templates/default/src/styles/globals.css +0 -55
- package/templates/default/src/x-routes.ts +0 -17
- package/templates/default/tsconfig.json +0 -5
- package/templates/default/x.config.ts +0 -6
- package/templates/landing/components.json +0 -20
- package/templates/landing/public/favicon.ico +0 -0
- package/templates/landing/src/components/code-block.tsx +0 -118
- package/templates/landing/src/components/ui/avatar.tsx +0 -91
- package/templates/landing/src/components/ui/badge.tsx +0 -49
- package/templates/landing/src/components/ui/button.tsx +0 -58
- package/templates/landing/src/components/ui/card.tsx +0 -88
- package/templates/landing/src/components/ui/input.tsx +0 -20
- package/templates/landing/src/layouts/main.tsx +0 -78
- package/templates/landing/src/lib/syntax.tsx +0 -366
- package/templates/landing/src/lib/utils.ts +0 -5
- package/templates/landing/src/pages/docs/_layout.tsx +0 -139
- package/templates/landing/src/pages/docs/api-routes.tsx +0 -113
- package/templates/landing/src/pages/docs/build-deploy.tsx +0 -124
- package/templates/landing/src/pages/docs/configuration.tsx +0 -121
- package/templates/landing/src/pages/docs/content-collections.tsx +0 -130
- package/templates/landing/src/pages/docs/data-layer.tsx +0 -142
- package/templates/landing/src/pages/docs/getting-started.tsx +0 -129
- package/templates/landing/src/pages/docs/index.tsx +0 -187
- package/templates/landing/src/pages/docs/installation.tsx +0 -143
- package/templates/landing/src/pages/docs/introduction.tsx +0 -114
- package/templates/landing/src/pages/docs/layouts.tsx +0 -114
- package/templates/landing/src/pages/docs/middleware.tsx +0 -124
- package/templates/landing/src/pages/docs/packages/cli.tsx +0 -133
- package/templates/landing/src/pages/docs/packages/core.tsx +0 -176
- package/templates/landing/src/pages/docs/packages/env.tsx +0 -128
- package/templates/landing/src/pages/docs/pages.tsx +0 -135
- package/templates/landing/src/pages/docs/routing.tsx +0 -123
- package/templates/landing/src/pages/docs/server-functions.tsx +0 -177
- package/templates/landing/src/pages/features.tsx +0 -129
- package/templates/landing/src/pages/index.tsx +0 -159
- package/templates/landing/src/styles/globals.css +0 -136
- package/templates/landing/src/x-routes.ts +0 -31
- package/templates/landing/tsconfig.json +0 -10
- package/templates/landing/x.config.ts +0 -2
- package/templates/saas/components.json +0 -20
- package/templates/saas/public/favicon.ico +0 -0
- package/templates/saas/src/actions/dashboard.ts +0 -3
- package/templates/saas/src/api/auth/login.ts +0 -31
- package/templates/saas/src/components/ui/avatar.tsx +0 -91
- package/templates/saas/src/components/ui/badge.tsx +0 -49
- package/templates/saas/src/components/ui/button.tsx +0 -58
- package/templates/saas/src/components/ui/card.tsx +0 -88
- package/templates/saas/src/components/ui/input.tsx +0 -20
- package/templates/saas/src/layouts/dashboard.tsx +0 -67
- package/templates/saas/src/layouts/main.tsx +0 -38
- package/templates/saas/src/lib/auth.ts +0 -91
- package/templates/saas/src/lib/migrations/001_create_sessions.sql +0 -9
- package/templates/saas/src/lib/utils.ts +0 -5
- package/templates/saas/src/pages/dashboard/_middleware.ts +0 -9
- package/templates/saas/src/pages/dashboard/analytics.tsx +0 -68
- package/templates/saas/src/pages/dashboard/index.tsx +0 -86
- package/templates/saas/src/pages/dashboard/settings.tsx +0 -111
- package/templates/saas/src/pages/index.tsx +0 -110
- package/templates/saas/src/pages/login.tsx +0 -140
- package/templates/saas/src/pages/pricing.tsx +0 -121
- package/templates/saas/src/styles/globals.css +0 -90
- package/templates/saas/src/x-routes.ts +0 -22
- package/templates/saas/tsconfig.json +0 -5
- package/templates/saas/x.config.ts +0 -7
- /package/templates/{basic → addons/auth}/src/api/auth/logout.ts +0 -0
- /package/templates/{basic → addons/auth}/src/pages/dashboard/_middleware.ts +0 -0
- /package/templates/{basic → addons/shadcn}/src/lib/utils.ts +0 -0
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import type { RouteProps } from "@thexjs/core";
|
|
2
|
-
import { ArrowRight } from "lucide-react";
|
|
3
|
-
import { CodeBlock } from "../../components/code-block";
|
|
4
|
-
|
|
5
|
-
export default function DocPage(_props: RouteProps) {
|
|
6
|
-
return (
|
|
7
|
-
<div>
|
|
8
|
-
<p className="text-xs font-semibold uppercase tracking-[0.2em] text-primary">Routing</p>
|
|
9
|
-
<h1 className="mt-4 text-3xl font-bold tracking-tight sm:text-4xl">File-based routing</h1>
|
|
10
|
-
<p className="mt-4 text-lg text-muted-foreground">
|
|
11
|
-
x uses the file system as your route table. Drop a file in{" "}
|
|
12
|
-
<span className="text-foreground">src/pages/</span>, get a route.
|
|
13
|
-
</p>
|
|
14
|
-
|
|
15
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">How it works</h2>
|
|
16
|
-
<p className="mt-3 text-muted-foreground">
|
|
17
|
-
Every <span className="text-foreground">.tsx</span> file in your pages directory becomes a
|
|
18
|
-
route. The file path determines the URL pattern.
|
|
19
|
-
</p>
|
|
20
|
-
|
|
21
|
-
<CodeBlock
|
|
22
|
-
label="routing table"
|
|
23
|
-
code={`pages/index.tsx -> /
|
|
24
|
-
pages/about.tsx -> /about
|
|
25
|
-
pages/contact.tsx -> /contact
|
|
26
|
-
pages/blog/index.tsx -> /blog
|
|
27
|
-
pages/blog/[slug].tsx -> /blog/:slug
|
|
28
|
-
pages/dashboard/
|
|
29
|
-
settings.tsx -> /dashboard/settings
|
|
30
|
-
profile.tsx -> /dashboard/profile
|
|
31
|
-
pages/_404.tsx -> catch-all 404`}
|
|
32
|
-
/>
|
|
33
|
-
|
|
34
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Static routes</h2>
|
|
35
|
-
<p className="mt-3 text-muted-foreground">
|
|
36
|
-
Simple files map to exact URL paths.{" "}
|
|
37
|
-
<span className="text-foreground">pages/about.tsx</span> becomes{" "}
|
|
38
|
-
<span className="text-foreground">/about</span>.
|
|
39
|
-
</p>
|
|
40
|
-
<CodeBlock
|
|
41
|
-
label="src/pages/about.tsx"
|
|
42
|
-
code={`export default function About() {
|
|
43
|
-
return <h1 className="text-3xl font-bold">About us</h1>;
|
|
44
|
-
}`}
|
|
45
|
-
/>
|
|
46
|
-
|
|
47
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Dynamic segments</h2>
|
|
48
|
-
<p className="mt-3 text-muted-foreground">
|
|
49
|
-
Wrap a filename in square brackets to create a dynamic segment. The value is available via
|
|
50
|
-
the <span className="text-foreground">params</span> object in loaders.
|
|
51
|
-
</p>
|
|
52
|
-
<CodeBlock
|
|
53
|
-
label="src/pages/blog/[slug].tsx"
|
|
54
|
-
code={`import type { RouteProps, LoaderArgs } from "@thexjs/core";
|
|
55
|
-
|
|
56
|
-
export async function loader({ params }: LoaderArgs) {
|
|
57
|
-
const post = await getPost(params.slug);
|
|
58
|
-
return { title: post.title, content: post.content };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export default function BlogPost({ loaderData }: RouteProps<typeof loader>) {
|
|
62
|
-
return (
|
|
63
|
-
<article>
|
|
64
|
-
<h1 className="text-3xl font-bold">{loaderData.title}</h1>
|
|
65
|
-
<div>{loaderData.content}</div>
|
|
66
|
-
</article>
|
|
67
|
-
);
|
|
68
|
-
}`}
|
|
69
|
-
/>
|
|
70
|
-
<p className="mt-4 text-muted-foreground">
|
|
71
|
-
Multiple dynamic segments work too:{" "}
|
|
72
|
-
<span className="text-foreground">pages/product/[category]/[id].tsx</span> →{" "}
|
|
73
|
-
<span className="text-foreground">/product/:category/:id</span>.
|
|
74
|
-
</p>
|
|
75
|
-
|
|
76
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Nested routes with folders</h2>
|
|
77
|
-
<p className="mt-3 text-muted-foreground">
|
|
78
|
-
Organize routes in folders for nested URL structures. Each folder can have its own{" "}
|
|
79
|
-
<span className="text-foreground">index.tsx</span>.
|
|
80
|
-
</p>
|
|
81
|
-
<CodeBlock
|
|
82
|
-
label="file tree"
|
|
83
|
-
lang="tree"
|
|
84
|
-
code={`pages/dashboard/
|
|
85
|
-
index.tsx -> /dashboard
|
|
86
|
-
settings.tsx -> /dashboard/settings
|
|
87
|
-
profile.tsx -> /dashboard/profile
|
|
88
|
-
billing/
|
|
89
|
-
index.tsx -> /dashboard/billing
|
|
90
|
-
history.tsx -> /dashboard/billing/history`}
|
|
91
|
-
/>
|
|
92
|
-
|
|
93
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Catch-all 404 page</h2>
|
|
94
|
-
<p className="mt-3 text-muted-foreground">
|
|
95
|
-
Create <span className="text-foreground">pages/_404.tsx</span> to show a custom not-found
|
|
96
|
-
page for unmatched routes.
|
|
97
|
-
</p>
|
|
98
|
-
<CodeBlock
|
|
99
|
-
label="src/pages/_404.tsx"
|
|
100
|
-
code={`export default function NotFound() {
|
|
101
|
-
return (
|
|
102
|
-
<div className="text-center py-20">
|
|
103
|
-
<h1 className="text-6xl font-bold text-muted-foreground">404</h1>
|
|
104
|
-
<p className="mt-4 text-lg text-muted-foreground">Page not found</p>
|
|
105
|
-
<a href="/docs" className="mt-6 inline-block text-primary hover:underline">
|
|
106
|
-
Go home
|
|
107
|
-
</a>
|
|
108
|
-
</div>
|
|
109
|
-
);
|
|
110
|
-
}`}
|
|
111
|
-
/>
|
|
112
|
-
|
|
113
|
-
<div className="mt-16 border-t border-border pt-8">
|
|
114
|
-
<a
|
|
115
|
-
href="/docs"
|
|
116
|
-
className="inline-flex items-center gap-1 text-sm text-muted-foreground transition-colors hover:text-foreground"
|
|
117
|
-
>
|
|
118
|
-
<ArrowRight className="h-3.5 w-3.5 rotate-180" /> Back to docs
|
|
119
|
-
</a>
|
|
120
|
-
</div>
|
|
121
|
-
</div>
|
|
122
|
-
);
|
|
123
|
-
}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import type { RouteProps } from "@thexjs/core";
|
|
2
|
-
import { ArrowRight } from "lucide-react";
|
|
3
|
-
import { CodeBlock } from "../../components/code-block";
|
|
4
|
-
|
|
5
|
-
export default function DocPage(_props: RouteProps) {
|
|
6
|
-
return (
|
|
7
|
-
<div>
|
|
8
|
-
<p className="text-xs font-semibold uppercase tracking-[0.2em] text-primary">
|
|
9
|
-
Server Functions
|
|
10
|
-
</p>
|
|
11
|
-
<h1 className="mt-4 text-3xl font-bold tracking-tight sm:text-4xl">Server functions</h1>
|
|
12
|
-
<p className="mt-4 text-lg text-muted-foreground">
|
|
13
|
-
Call server-side functions from the browser without writing REST endpoints. Server functions
|
|
14
|
-
live in <span className="text-foreground">src/actions/</span>. Import one into a client
|
|
15
|
-
component and call it like a normal function, or call it manually with{" "}
|
|
16
|
-
<span className="text-foreground">fetch</span> — both compile down to the same request.
|
|
17
|
-
</p>
|
|
18
|
-
|
|
19
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Defining server functions</h2>
|
|
20
|
-
<p className="mt-3 text-muted-foreground">
|
|
21
|
-
Create a file in <span className="text-foreground">src/actions/</span> and export named
|
|
22
|
-
async functions. Each function receives a <span className="text-foreground">Request</span>{" "}
|
|
23
|
-
object and any arguments you pass.
|
|
24
|
-
</p>
|
|
25
|
-
<CodeBlock
|
|
26
|
-
label="src/actions/greet.ts"
|
|
27
|
-
code={`export async function greet(name: string) {
|
|
28
|
-
return \`Hello, ${"$"}{name}! The server time is ${"$"}{new Date().toISOString()}.\`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export async function sendEmail({ to, subject, body }: {
|
|
32
|
-
to: string;
|
|
33
|
-
subject: string;
|
|
34
|
-
body: string;
|
|
35
|
-
}) {
|
|
36
|
-
// send email logic
|
|
37
|
-
return { sent: true, to };
|
|
38
|
-
}`}
|
|
39
|
-
/>
|
|
40
|
-
|
|
41
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Calling actions directly</h2>
|
|
42
|
-
<p className="mt-3 text-muted-foreground">
|
|
43
|
-
Import the function into a client component and call it like any other async function. When
|
|
44
|
-
you run <span className="text-foreground">x build</span>, the bundler swaps the import for a
|
|
45
|
-
generated fetch client before it reaches the browser, so the real implementation, db calls
|
|
46
|
-
and all, never gets bundled.
|
|
47
|
-
</p>
|
|
48
|
-
<CodeBlock
|
|
49
|
-
label="client component"
|
|
50
|
-
code={`"use client";
|
|
51
|
-
|
|
52
|
-
import { useState } from "react";
|
|
53
|
-
import { subscribeUser } from "../actions/subscribe";
|
|
54
|
-
|
|
55
|
-
export default function SubscribeForm() {
|
|
56
|
-
const [status, setStatus] = useState("");
|
|
57
|
-
|
|
58
|
-
async function handleSubmit(e: React.FormEvent) {
|
|
59
|
-
e.preventDefault();
|
|
60
|
-
const form = new FormData(e.target as HTMLFormElement);
|
|
61
|
-
const email = form.get("email") as string;
|
|
62
|
-
|
|
63
|
-
await subscribeUser(email);
|
|
64
|
-
setStatus("Subscribed!");
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<form onSubmit={handleSubmit} className="space-y-4">
|
|
69
|
-
<input
|
|
70
|
-
name="email"
|
|
71
|
-
type="email"
|
|
72
|
-
placeholder="you@example.com"
|
|
73
|
-
className="rounded-xl border border-border bg-card px-4 py-2"
|
|
74
|
-
/>
|
|
75
|
-
<button type="submit" className="rounded-xl bg-primary px-4 py-2 text-primary-foreground">
|
|
76
|
-
Subscribe
|
|
77
|
-
</button>
|
|
78
|
-
{status && <p className="text-muted-foreground">{status}</p>}
|
|
79
|
-
</form>
|
|
80
|
-
);
|
|
81
|
-
}`}
|
|
82
|
-
/>
|
|
83
|
-
<p className="mt-3 text-sm text-muted-foreground">
|
|
84
|
-
Only files under <span className="text-foreground">actionsDir</span> get this treatment.
|
|
85
|
-
Import a regular server-only helper into client code and it bundles as-is; if it leaks a
|
|
86
|
-
secret, the build-time env isolation check catches it instead.
|
|
87
|
-
</p>
|
|
88
|
-
|
|
89
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Calling manually with fetch</h2>
|
|
90
|
-
<p className="mt-3 text-muted-foreground">
|
|
91
|
-
This is what the direct-import style compiles down to, and it works the same way in dev and
|
|
92
|
-
in production: a POST request to{" "}
|
|
93
|
-
<span className="text-foreground">/__x/actions/<filename>/<functionName></span>.
|
|
94
|
-
The arguments are sent as JSON in the request body.
|
|
95
|
-
</p>
|
|
96
|
-
<CodeBlock
|
|
97
|
-
label="client component"
|
|
98
|
-
code={`"use client";
|
|
99
|
-
|
|
100
|
-
import { useState } from "react";
|
|
101
|
-
|
|
102
|
-
export default function GreetForm() {
|
|
103
|
-
const [message, setMessage] = useState("");
|
|
104
|
-
|
|
105
|
-
async function handleSubmit(e: React.FormEvent) {
|
|
106
|
-
e.preventDefault();
|
|
107
|
-
const form = new FormData(e.target as HTMLFormElement);
|
|
108
|
-
const name = form.get("name");
|
|
109
|
-
|
|
110
|
-
const res = await fetch("/__x/actions/greet/greet", {
|
|
111
|
-
method: "POST",
|
|
112
|
-
headers: { "Content-Type": "application/json" },
|
|
113
|
-
body: JSON.stringify([name]),
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
const data = await res.text();
|
|
117
|
-
setMessage(data);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return (
|
|
121
|
-
<form onSubmit={handleSubmit} className="space-y-4">
|
|
122
|
-
<input
|
|
123
|
-
name="name"
|
|
124
|
-
placeholder="Enter your name"
|
|
125
|
-
className="rounded-xl border border-border bg-card px-4 py-2"
|
|
126
|
-
/>
|
|
127
|
-
<button type="submit" className="rounded-xl bg-primary px-4 py-2 text-primary-foreground">
|
|
128
|
-
Greet me
|
|
129
|
-
</button>
|
|
130
|
-
{message && <p className="text-muted-foreground">{message}</p>}
|
|
131
|
-
</form>
|
|
132
|
-
);
|
|
133
|
-
}`}
|
|
134
|
-
/>
|
|
135
|
-
<p className="mt-3 text-sm text-muted-foreground">
|
|
136
|
-
Reach for this style directly when you're calling an action from outside an island, or
|
|
137
|
-
anywhere you'd rather see the request explicitly.
|
|
138
|
-
</p>
|
|
139
|
-
|
|
140
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Server functions from loaders</h2>
|
|
141
|
-
<p className="mt-3 text-muted-foreground">
|
|
142
|
-
You can also import and call server functions directly in loaders — no HTTP needed since
|
|
143
|
-
they share the same process.
|
|
144
|
-
</p>
|
|
145
|
-
<CodeBlock
|
|
146
|
-
label="src/pages/dashboard.tsx"
|
|
147
|
-
code={`import type { RouteProps, LoaderArgs } from "@thexjs/core";
|
|
148
|
-
import { getDashboardData } from "../actions/dashboard";
|
|
149
|
-
|
|
150
|
-
export async function loader({ request }: LoaderArgs) {
|
|
151
|
-
const data = await getDashboardData();
|
|
152
|
-
return { data };
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export default function Dashboard({ loaderData }: RouteProps<typeof loader>) {
|
|
156
|
-
return <div>...</div>;
|
|
157
|
-
}`}
|
|
158
|
-
/>
|
|
159
|
-
|
|
160
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Use cases</h2>
|
|
161
|
-
<p className="mt-3 text-muted-foreground">
|
|
162
|
-
Server functions are ideal for form handling, sending emails, database mutations, and any
|
|
163
|
-
server-side logic that doesn't need a dedicated REST API. They reduce boilerplate and keep
|
|
164
|
-
your client code simple.
|
|
165
|
-
</p>
|
|
166
|
-
|
|
167
|
-
<div className="mt-16 border-t border-border pt-8">
|
|
168
|
-
<a
|
|
169
|
-
href="/docs"
|
|
170
|
-
className="inline-flex items-center gap-1 text-sm text-muted-foreground transition-colors hover:text-foreground"
|
|
171
|
-
>
|
|
172
|
-
<ArrowRight className="h-3.5 w-3.5 rotate-180" /> Back to docs
|
|
173
|
-
</a>
|
|
174
|
-
</div>
|
|
175
|
-
</div>
|
|
176
|
-
);
|
|
177
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ArrowRight,
|
|
3
|
-
BarChart3,
|
|
4
|
-
Box,
|
|
5
|
-
Code2,
|
|
6
|
-
FileJson,
|
|
7
|
-
Globe,
|
|
8
|
-
Layers,
|
|
9
|
-
RefreshCw,
|
|
10
|
-
Server,
|
|
11
|
-
Shield,
|
|
12
|
-
Sparkles,
|
|
13
|
-
Zap,
|
|
14
|
-
} from "lucide-react";
|
|
15
|
-
|
|
16
|
-
const allFeatures = [
|
|
17
|
-
{
|
|
18
|
-
icon: Zap,
|
|
19
|
-
title: "One process, everything included",
|
|
20
|
-
desc: "Static sites, SSR, API routes, and server functions all run in a single Bun process. No microservices, no orchestration, no separate API server.",
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
icon: FileJson,
|
|
24
|
-
title: "File-based routing",
|
|
25
|
-
desc: "Your file tree is your route tree. Drop a page in src/pages/ and it's immediately available. Dynamic segments, nested routes, and catch-all 404s come for free.",
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
icon: Layers,
|
|
29
|
-
title: "Static + dynamic hybrid",
|
|
30
|
-
desc: "Pick the right rendering mode per route. Use mode='static' for prerendered marketing pages, and server mode for personalized dashboards — all in the same project.",
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
icon: Globe,
|
|
34
|
-
title: "API routes built in",
|
|
35
|
-
desc: "Build REST endpoints alongside your frontend. Shared types, same process, zero config. Middleware support for auth, validation, and logging.",
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
icon: Server,
|
|
39
|
-
title: "Server functions",
|
|
40
|
-
desc: "Call server-side functions from the browser without writing REST endpoints. Import them into a client component and call them directly, or by hand with fetch.",
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
icon: Shield,
|
|
44
|
-
title: "Type safe end to end",
|
|
45
|
-
desc: "TypeScript from loader to component. LoaderData is typed through RouteProps, params are inferred from file paths, and server functions are fully typed.",
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
icon: BarChart3,
|
|
49
|
-
title: "Content collections",
|
|
50
|
-
desc: "Write markdown files with frontmatter and x turns them into pages. Built-in rendering with code highlighting, slug generation, and frontmatter parsing.",
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
icon: Sparkles,
|
|
54
|
-
title: "Live reload",
|
|
55
|
-
desc: "See changes instantly. The dev server watches pages, layouts, API routes, and actions. No manual restarts, no build step during development.",
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
icon: Box,
|
|
59
|
-
title: "Optimized production builds",
|
|
60
|
-
desc: "One command produces static HTML, a server bundle, and a build manifest. Deploy anywhere Bun runs — Fly.io, Railway, Docker, or a VPS.",
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
icon: Code2,
|
|
64
|
-
title: "Islands architecture",
|
|
65
|
-
desc: "Interactive client components hydrate in place. The rest of the page is static HTML. Minimal JavaScript, maximum performance.",
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
icon: RefreshCw,
|
|
69
|
-
title: "Database integration",
|
|
70
|
-
desc: "Built-in SQLite and PostgreSQL support with migrations. Query databases directly from loaders and server functions with prepared statements.",
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
icon: ArrowRight,
|
|
74
|
-
title: "Open source",
|
|
75
|
-
desc: "MIT licensed. Contributions welcome. Built for Bun with modern JavaScript in mind. No lock-in, no proprietary formats.",
|
|
76
|
-
},
|
|
77
|
-
];
|
|
78
|
-
|
|
79
|
-
export default function FeaturesPage() {
|
|
80
|
-
return (
|
|
81
|
-
<div className="mx-auto max-w-6xl px-6 py-20">
|
|
82
|
-
<div className="mx-auto max-w-2xl text-center">
|
|
83
|
-
<p className="text-xs font-semibold uppercase tracking-[0.2em] text-primary">Features</p>
|
|
84
|
-
<h1 className="mt-4 text-4xl font-bold tracking-tight sm:text-5xl">
|
|
85
|
-
Everything you need to build for the web
|
|
86
|
-
</h1>
|
|
87
|
-
<p className="mt-4 text-lg text-muted-foreground">
|
|
88
|
-
x combines static generation, server rendering, APIs, and server functions in a single Bun
|
|
89
|
-
process — with zero configuration.
|
|
90
|
-
</p>
|
|
91
|
-
</div>
|
|
92
|
-
|
|
93
|
-
<div className="mt-16 grid gap-px overflow-hidden rounded-2xl border border-border bg-border sm:grid-cols-2 lg:grid-cols-3">
|
|
94
|
-
{allFeatures.map((f) => (
|
|
95
|
-
<div key={f.title} className="bg-card p-8 transition-colors hover:bg-card/80">
|
|
96
|
-
<div className="flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary">
|
|
97
|
-
<f.icon className="h-5 w-5" />
|
|
98
|
-
</div>
|
|
99
|
-
<h3 className="mt-5 text-lg font-semibold">{f.title}</h3>
|
|
100
|
-
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">{f.desc}</p>
|
|
101
|
-
</div>
|
|
102
|
-
))}
|
|
103
|
-
</div>
|
|
104
|
-
|
|
105
|
-
<div className="mt-16">
|
|
106
|
-
<div className="rounded-3xl border border-primary/20 bg-gradient-to-b from-primary/5 to-transparent p-12 text-center sm:p-20">
|
|
107
|
-
<h2 className="text-3xl font-bold tracking-tight sm:text-4xl">Ready to build with x?</h2>
|
|
108
|
-
<p className="mt-4 text-lg text-muted-foreground">
|
|
109
|
-
One command, one process, everything you need.
|
|
110
|
-
</p>
|
|
111
|
-
<div className="mt-8 flex flex-wrap items-center justify-center gap-4">
|
|
112
|
-
<a
|
|
113
|
-
href="/docs/getting-started"
|
|
114
|
-
className="inline-flex h-12 items-center gap-2 rounded-xl bg-primary px-6 text-sm font-semibold text-primary-foreground shadow-lg shadow-primary/25 transition-all hover:bg-primary/90"
|
|
115
|
-
>
|
|
116
|
-
Get started <ArrowRight className="h-4 w-4" />
|
|
117
|
-
</a>
|
|
118
|
-
<a
|
|
119
|
-
href="/docs"
|
|
120
|
-
className="inline-flex h-12 items-center gap-2 rounded-xl border border-border bg-card px-6 text-sm font-medium text-foreground transition-all hover:bg-muted"
|
|
121
|
-
>
|
|
122
|
-
Read the docs
|
|
123
|
-
</a>
|
|
124
|
-
</div>
|
|
125
|
-
</div>
|
|
126
|
-
</div>
|
|
127
|
-
</div>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { ArrowRight, BookOpen, Code2, FileJson, Globe, Layers, Shield, Zap } from "lucide-react";
|
|
2
|
-
import { TerminalBlock } from "../components/code-block";
|
|
3
|
-
|
|
4
|
-
const features = [
|
|
5
|
-
{
|
|
6
|
-
icon: Zap,
|
|
7
|
-
title: "One process",
|
|
8
|
-
desc: "Static sites, SSR, API routes, and server functions — no microservices, no orchestration.",
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
icon: FileJson,
|
|
12
|
-
title: "File-based routing",
|
|
13
|
-
desc: "Drop a file in src/pages, get a route. Nested folders, dynamic segments, API routes — automatic.",
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
icon: Layers,
|
|
17
|
-
title: "Static + dynamic",
|
|
18
|
-
desc: "Mix static generation with SSR on the same route. Prerender marketing pages, SSR dashboards and admin.",
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
icon: Globe,
|
|
22
|
-
title: "API routes",
|
|
23
|
-
desc: "Build REST endpoints alongside your pages. Shared types, same process, no separate server needed.",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
icon: Shield,
|
|
27
|
-
title: "Type safe",
|
|
28
|
-
desc: "End-to-end TypeScript. Loaders, params, server functions — all typed from the framework to your components.",
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
icon: Code2,
|
|
32
|
-
title: "Island architecture",
|
|
33
|
-
desc: "Interactive components hydrate in place. Minimal client JS — only what you mark as an island loads.",
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
export const mode = "static";
|
|
38
|
-
|
|
39
|
-
export default function HomePage() {
|
|
40
|
-
return (
|
|
41
|
-
<div className="pb-32">
|
|
42
|
-
<section className="relative overflow-hidden px-6 pt-16 pb-24 sm:pt-20">
|
|
43
|
-
<div
|
|
44
|
-
className="pointer-events-none absolute inset-0 opacity-30"
|
|
45
|
-
style={{
|
|
46
|
-
backgroundImage:
|
|
47
|
-
"linear-gradient(to right, #1a2233 1px, transparent 1px), linear-gradient(to bottom, #1a2233 1px, transparent 1px)",
|
|
48
|
-
backgroundSize: "40px 40px",
|
|
49
|
-
maskImage: "radial-gradient(ellipse 80% 70% at 50% 0%, black 10%, transparent 100%)",
|
|
50
|
-
}}
|
|
51
|
-
/>
|
|
52
|
-
<div className="pointer-events-none absolute -top-32 left-1/2 h-[520px] w-[520px] -translate-x-1/2 animate-pulse-glow rounded-full bg-primary/10 blur-3xl" />
|
|
53
|
-
|
|
54
|
-
<div className="relative z-10 mx-auto grid max-w-6xl items-center gap-14 lg:grid-cols-[1fr_1.05fr] lg:gap-10">
|
|
55
|
-
<div>
|
|
56
|
-
<p className="font-mono text-[11px] uppercase tracking-[0.28em] text-primary">
|
|
57
|
-
Bun-native fullstack
|
|
58
|
-
</p>
|
|
59
|
-
<h1 className="mt-5 text-[clamp(2.4rem,6vw,4.25rem)] font-extrabold leading-[1.02]">
|
|
60
|
-
Files in.
|
|
61
|
-
<br />
|
|
62
|
-
<span className="text-primary">Routes out.</span>
|
|
63
|
-
</h1>
|
|
64
|
-
<p className="mt-6 max-w-lg text-base leading-relaxed text-muted-foreground sm:text-lg">
|
|
65
|
-
x is a React framework where your folder structure is the router, your API lives
|
|
66
|
-
beside your pages, and everything runs in one Bun process.
|
|
67
|
-
</p>
|
|
68
|
-
<div className="mt-9 flex flex-wrap gap-3">
|
|
69
|
-
<a
|
|
70
|
-
href="/docs/installation"
|
|
71
|
-
className="group inline-flex h-11 items-center gap-2 rounded-xl bg-primary px-5 text-sm font-semibold text-primary-foreground shadow-lg shadow-primary/25 transition-all hover:bg-primary/90 active:scale-[0.98]"
|
|
72
|
-
>
|
|
73
|
-
Install x
|
|
74
|
-
<ArrowRight className="h-4 w-4 transition-transform group-hover:translate-x-0.5" />
|
|
75
|
-
</a>
|
|
76
|
-
<a
|
|
77
|
-
href="/docs/introduction"
|
|
78
|
-
className="inline-flex h-11 items-center gap-2 rounded-xl border border-border bg-card/60 px-5 text-sm font-medium backdrop-blur-sm transition-colors hover:bg-muted"
|
|
79
|
-
>
|
|
80
|
-
<BookOpen className="h-4 w-4" /> Introduction
|
|
81
|
-
</a>
|
|
82
|
-
</div>
|
|
83
|
-
</div>
|
|
84
|
-
|
|
85
|
-
<div className="relative">
|
|
86
|
-
<div className="absolute -inset-4 rounded-3xl bg-gradient-to-br from-primary/10 via-transparent to-secondary/5 blur-2xl" />
|
|
87
|
-
<TerminalBlock
|
|
88
|
-
label="~/my-app — zsh"
|
|
89
|
-
code={`$ bun create thexjs-app@latest my-app
|
|
90
|
-
|
|
91
|
-
Available templates:
|
|
92
|
-
|
|
93
|
-
default Blank slate — single home page. (recommended)
|
|
94
|
-
basic Pages, API, auth, dashboard.
|
|
95
|
-
blog Markdown content collections.
|
|
96
|
-
saas Dashboard, pricing, data layer.
|
|
97
|
-
|
|
98
|
-
Choose a template (default): █
|
|
99
|
-
|
|
100
|
-
$ cd my-app && bun run dev
|
|
101
|
-
[x] dev server running at http://localhost:3000`}
|
|
102
|
-
/>
|
|
103
|
-
</div>
|
|
104
|
-
</div>
|
|
105
|
-
</section>
|
|
106
|
-
|
|
107
|
-
<section className="mx-auto max-w-6xl px-6">
|
|
108
|
-
<div className="mx-auto max-w-2xl text-center">
|
|
109
|
-
<p className="font-mono text-[11px] uppercase tracking-[0.22em] text-primary">Why x</p>
|
|
110
|
-
<h2 className="mt-4 text-3xl font-bold sm:text-4xl">Everything in one place</h2>
|
|
111
|
-
<p className="mt-4 text-muted-foreground">
|
|
112
|
-
Most frameworks split the stack. x keeps routing, rendering, API, and build tooling in
|
|
113
|
-
one runtime.
|
|
114
|
-
</p>
|
|
115
|
-
</div>
|
|
116
|
-
<div className="mt-14 grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
|
117
|
-
{features.map((f) => (
|
|
118
|
-
<article
|
|
119
|
-
key={f.title}
|
|
120
|
-
className="group rounded-2xl border border-border/80 bg-card/50 p-6 transition-colors hover:border-primary/25 hover:bg-card"
|
|
121
|
-
>
|
|
122
|
-
<div className="flex h-9 w-9 items-center justify-center rounded-lg border border-border bg-muted/50 text-primary transition-colors group-hover:border-primary/30 group-hover:bg-primary/10">
|
|
123
|
-
<f.icon className="h-4 w-4" />
|
|
124
|
-
</div>
|
|
125
|
-
<h3 className="mt-4 font-semibold">{f.title}</h3>
|
|
126
|
-
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">{f.desc}</p>
|
|
127
|
-
</article>
|
|
128
|
-
))}
|
|
129
|
-
</div>
|
|
130
|
-
</section>
|
|
131
|
-
|
|
132
|
-
<section className="mx-auto mt-28 max-w-4xl px-6">
|
|
133
|
-
<div className="rounded-3xl border border-border/80 bg-card/40 p-10 text-center sm:p-14">
|
|
134
|
-
<h2 className="text-3xl font-bold sm:text-4xl">Ready to build?</h2>
|
|
135
|
-
<p className="mx-auto mt-4 max-w-lg text-muted-foreground">
|
|
136
|
-
Read the docs, scaffold a project, and ship from a single home page or a full-stack
|
|
137
|
-
starter.
|
|
138
|
-
</p>
|
|
139
|
-
<div className="mt-8 flex flex-wrap items-center justify-center gap-3">
|
|
140
|
-
<a
|
|
141
|
-
href="/docs"
|
|
142
|
-
className="inline-flex h-11 items-center gap-2 rounded-xl bg-primary px-5 text-sm font-semibold text-primary-foreground shadow-lg shadow-primary/20 transition-all hover:bg-primary/90"
|
|
143
|
-
>
|
|
144
|
-
<BookOpen className="h-4 w-4" /> Read the docs
|
|
145
|
-
</a>
|
|
146
|
-
<a
|
|
147
|
-
href="https://github.com/abdelkabirouadoukou/x"
|
|
148
|
-
target="_blank"
|
|
149
|
-
rel="noopener noreferrer"
|
|
150
|
-
className="inline-flex h-11 items-center rounded-xl border border-border px-5 text-sm font-medium transition-colors hover:bg-muted"
|
|
151
|
-
>
|
|
152
|
-
GitHub
|
|
153
|
-
</a>
|
|
154
|
-
</div>
|
|
155
|
-
</div>
|
|
156
|
-
</section>
|
|
157
|
-
</div>
|
|
158
|
-
);
|
|
159
|
-
}
|