create-thexjs-app 0.1.4 → 1.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/README.md +56 -985
- package/dist/index.js +265 -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/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,187 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ArrowRight,
|
|
3
|
-
BookOpen,
|
|
4
|
-
Box,
|
|
5
|
-
Code2,
|
|
6
|
-
Cog,
|
|
7
|
-
Database,
|
|
8
|
-
FileJson,
|
|
9
|
-
Globe,
|
|
10
|
-
Layers,
|
|
11
|
-
Layout,
|
|
12
|
-
Package,
|
|
13
|
-
Rocket,
|
|
14
|
-
Shield,
|
|
15
|
-
Terminal,
|
|
16
|
-
Zap,
|
|
17
|
-
} from "lucide-react";
|
|
18
|
-
|
|
19
|
-
const startSections = [
|
|
20
|
-
{
|
|
21
|
-
icon: BookOpen,
|
|
22
|
-
title: "Introduction",
|
|
23
|
-
desc: "What x is, how the packages fit together, and a minimal page.",
|
|
24
|
-
href: "/docs/introduction",
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
icon: Terminal,
|
|
28
|
-
title: "Installation",
|
|
29
|
-
desc: "Prerequisites, create command, templates, and manual setup.",
|
|
30
|
-
href: "/docs/installation",
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
icon: Rocket,
|
|
34
|
-
title: "Getting Started",
|
|
35
|
-
desc: "Project structure, your first page, and running the dev server.",
|
|
36
|
-
href: "/docs/getting-started",
|
|
37
|
-
},
|
|
38
|
-
];
|
|
39
|
-
|
|
40
|
-
const packageSections = [
|
|
41
|
-
{
|
|
42
|
-
icon: Package,
|
|
43
|
-
title: "@thexjs/core",
|
|
44
|
-
desc: "Rendering engine — routing, SSR/SSG, islands, server functions, data layer.",
|
|
45
|
-
href: "/docs/packages/core",
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
icon: Terminal,
|
|
49
|
-
title: "@thexjs/cli",
|
|
50
|
-
desc: "The x command — dev, build, start, and deployment output.",
|
|
51
|
-
href: "/docs/packages/cli",
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
icon: Box,
|
|
55
|
-
title: "@thexjs/env",
|
|
56
|
-
desc: "Type-safe environment variable validation with fail-fast errors.",
|
|
57
|
-
href: "/docs/packages/env",
|
|
58
|
-
},
|
|
59
|
-
];
|
|
60
|
-
|
|
61
|
-
const guideSections = [
|
|
62
|
-
{
|
|
63
|
-
icon: Globe,
|
|
64
|
-
title: "Routing",
|
|
65
|
-
desc: "File-based routing: static pages, dynamic segments, nested routes.",
|
|
66
|
-
href: "/docs/routing",
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
icon: FileJson,
|
|
70
|
-
title: "Pages & Loaders",
|
|
71
|
-
desc: "Static pages, server-rendered pages, and data loading.",
|
|
72
|
-
href: "/docs/pages",
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
icon: Layout,
|
|
76
|
-
title: "Layouts",
|
|
77
|
-
desc: "Nested layouts, dedicated layout directories, and root layouts.",
|
|
78
|
-
href: "/docs/layouts",
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
icon: Code2,
|
|
82
|
-
title: "API Routes",
|
|
83
|
-
desc: "Build REST endpoints alongside your frontend pages.",
|
|
84
|
-
href: "/docs/api-routes",
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
icon: Zap,
|
|
88
|
-
title: "Server Functions",
|
|
89
|
-
desc: "Call server-side functions from the browser without REST.",
|
|
90
|
-
href: "/docs/server-functions",
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
icon: Layers,
|
|
94
|
-
title: "Content Collections",
|
|
95
|
-
desc: "Markdown files with frontmatter that become routes.",
|
|
96
|
-
href: "/docs/content-collections",
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
icon: Shield,
|
|
100
|
-
title: "Middleware",
|
|
101
|
-
desc: "Route-level middleware for auth, redirects, and validation.",
|
|
102
|
-
href: "/docs/middleware",
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
icon: Database,
|
|
106
|
-
title: "Data Layer",
|
|
107
|
-
desc: "SQLite and PostgreSQL integration with migrations.",
|
|
108
|
-
href: "/docs/data-layer",
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
icon: Rocket,
|
|
112
|
-
title: "Build & Deploy",
|
|
113
|
-
desc: "Production builds, static export, and deployment.",
|
|
114
|
-
href: "/docs/build-deploy",
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
icon: Cog,
|
|
118
|
-
title: "Configuration",
|
|
119
|
-
desc: "x.config.ts reference — all options and defaults.",
|
|
120
|
-
href: "/docs/configuration",
|
|
121
|
-
},
|
|
122
|
-
];
|
|
123
|
-
|
|
124
|
-
function SectionGrid({
|
|
125
|
-
sections,
|
|
126
|
-
}: {
|
|
127
|
-
sections: typeof startSections;
|
|
128
|
-
}) {
|
|
129
|
-
return (
|
|
130
|
-
<div className="grid gap-4 sm:grid-cols-2">
|
|
131
|
-
{sections.map((s) => (
|
|
132
|
-
<a
|
|
133
|
-
key={s.title}
|
|
134
|
-
href={s.href}
|
|
135
|
-
className="group rounded-2xl border border-border bg-card p-6 transition-all hover:border-primary/30 hover:shadow-lg hover:shadow-primary/5"
|
|
136
|
-
>
|
|
137
|
-
<div className="flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary transition-colors group-hover:bg-primary/20">
|
|
138
|
-
<s.icon className="h-5 w-5" />
|
|
139
|
-
</div>
|
|
140
|
-
<h3 className="mt-4 text-lg font-semibold transition-colors group-hover:text-primary">
|
|
141
|
-
{s.title}
|
|
142
|
-
</h3>
|
|
143
|
-
<p className="mt-1 text-sm text-muted-foreground">{s.desc}</p>
|
|
144
|
-
<span className="mt-3 inline-flex items-center gap-1 text-xs font-medium text-primary opacity-0 transition-opacity group-hover:opacity-100">
|
|
145
|
-
Read more <ArrowRight className="h-3 w-3" />
|
|
146
|
-
</span>
|
|
147
|
-
</a>
|
|
148
|
-
))}
|
|
149
|
-
</div>
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export const mode = "static";
|
|
154
|
-
|
|
155
|
-
export default function DocsHubPage() {
|
|
156
|
-
return (
|
|
157
|
-
<div className="py-12">
|
|
158
|
-
<div className="mb-12">
|
|
159
|
-
<p className="text-xs font-semibold uppercase tracking-[0.2em] text-primary">
|
|
160
|
-
Documentation
|
|
161
|
-
</p>
|
|
162
|
-
<h1 className="mt-4 text-4xl font-bold tracking-tight sm:text-5xl">
|
|
163
|
-
Everything you need to build with x
|
|
164
|
-
</h1>
|
|
165
|
-
<p className="mt-4 text-lg text-muted-foreground">
|
|
166
|
-
A fullstack framework for Bun. Static sites, server-rendered pages, API routes, and server
|
|
167
|
-
functions — all in a single process.
|
|
168
|
-
</p>
|
|
169
|
-
</div>
|
|
170
|
-
|
|
171
|
-
<h2 className="mb-4 text-sm font-semibold uppercase tracking-[0.15em] text-muted-foreground">
|
|
172
|
-
Start here
|
|
173
|
-
</h2>
|
|
174
|
-
<SectionGrid sections={startSections} />
|
|
175
|
-
|
|
176
|
-
<h2 className="mb-4 mt-12 text-sm font-semibold uppercase tracking-[0.15em] text-muted-foreground">
|
|
177
|
-
Packages
|
|
178
|
-
</h2>
|
|
179
|
-
<SectionGrid sections={packageSections} />
|
|
180
|
-
|
|
181
|
-
<h2 className="mb-4 mt-12 text-sm font-semibold uppercase tracking-[0.15em] text-muted-foreground">
|
|
182
|
-
Guides
|
|
183
|
-
</h2>
|
|
184
|
-
<SectionGrid sections={guideSections} />
|
|
185
|
-
</div>
|
|
186
|
-
);
|
|
187
|
-
}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import type { RouteProps } from "@thexjs/core";
|
|
2
|
-
import { ArrowRight } from "lucide-react";
|
|
3
|
-
import { CodeBlock, TerminalBlock } from "../../components/code-block";
|
|
4
|
-
|
|
5
|
-
export const mode = "static";
|
|
6
|
-
|
|
7
|
-
export default function DocPage(_props: RouteProps) {
|
|
8
|
-
return (
|
|
9
|
-
<div>
|
|
10
|
-
<p className="text-xs font-semibold uppercase tracking-[0.2em] text-primary">Installation</p>
|
|
11
|
-
<h1 className="mt-4 text-3xl font-bold tracking-tight sm:text-4xl">Install x</h1>
|
|
12
|
-
<p className="mt-4 text-lg text-muted-foreground">
|
|
13
|
-
x requires the Bun runtime. Scaffold a new project with the create command, or add the
|
|
14
|
-
packages manually to an existing app.
|
|
15
|
-
</p>
|
|
16
|
-
|
|
17
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Prerequisites</h2>
|
|
18
|
-
<p className="mt-3 text-muted-foreground">
|
|
19
|
-
Install{" "}
|
|
20
|
-
<a href="https://bun.sh" className="text-primary underline underline-offset-2">
|
|
21
|
-
Bun
|
|
22
|
-
</a>{" "}
|
|
23
|
-
— x uses <span className="text-foreground">Bun.serve</span>,{" "}
|
|
24
|
-
<span className="text-foreground">Bun.file</span>, and other Bun-only APIs. Verify with:
|
|
25
|
-
</p>
|
|
26
|
-
<TerminalBlock label="terminal — bun" code="bun --version" />
|
|
27
|
-
|
|
28
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Create a new project</h2>
|
|
29
|
-
<p className="mt-3 text-muted-foreground">
|
|
30
|
-
The fastest path is the project scaffolder. It copies a template, generates{" "}
|
|
31
|
-
<span className="text-foreground">package.json</span>, resolves the latest{" "}
|
|
32
|
-
<span className="text-foreground">@thexjs/core</span> and{" "}
|
|
33
|
-
<span className="text-foreground">@thexjs/cli</span> versions, and runs{" "}
|
|
34
|
-
<span className="text-foreground">bun install</span>.
|
|
35
|
-
</p>
|
|
36
|
-
<TerminalBlock
|
|
37
|
-
label="~/projects — zsh"
|
|
38
|
-
code={`bun create thexjs-app@latest my-app
|
|
39
|
-
cd my-app
|
|
40
|
-
bun run dev`}
|
|
41
|
-
/>
|
|
42
|
-
<p className="mt-4 text-muted-foreground">
|
|
43
|
-
When prompted for a template, press Enter to accept{" "}
|
|
44
|
-
<span className="text-foreground">default</span> (recommended) — a single home page to start
|
|
45
|
-
from. Other templates include <span className="text-foreground">basic</span>,{" "}
|
|
46
|
-
<span className="text-foreground">blog</span>, <span className="text-foreground">saas</span>
|
|
47
|
-
, and <span className="text-foreground">landing</span>.
|
|
48
|
-
</p>
|
|
49
|
-
<TerminalBlock
|
|
50
|
-
label="template selection"
|
|
51
|
-
code={`Available templates:
|
|
52
|
-
|
|
53
|
-
default Blank slate with a single home page. (recommended)
|
|
54
|
-
basic Minimal starter: pages, API route, auth, dashboard.
|
|
55
|
-
blog Markdown content collections.
|
|
56
|
-
saas Dashboard, settings, pricing, auth, data layer.
|
|
57
|
-
landing Marketing site with docs pages.
|
|
58
|
-
|
|
59
|
-
Choose a template (default/basic/blog/saas/landing) (default):`}
|
|
60
|
-
/>
|
|
61
|
-
<p className="mt-4 text-muted-foreground">
|
|
62
|
-
Pass a template explicitly with <span className="text-foreground">--template</span> or{" "}
|
|
63
|
-
<span className="text-foreground">-t</span>:
|
|
64
|
-
</p>
|
|
65
|
-
<TerminalBlock
|
|
66
|
-
label="~/projects — zsh"
|
|
67
|
-
code="bun create thexjs-app@latest my-app --template default"
|
|
68
|
-
/>
|
|
69
|
-
|
|
70
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Add to an existing project</h2>
|
|
71
|
-
<p className="mt-3 text-muted-foreground">
|
|
72
|
-
Install the core packages and wire up scripts in{" "}
|
|
73
|
-
<span className="text-foreground">package.json</span>:
|
|
74
|
-
</p>
|
|
75
|
-
<CodeBlock
|
|
76
|
-
label="terminal"
|
|
77
|
-
lang="bash"
|
|
78
|
-
code={`bun add @thexjs/core
|
|
79
|
-
bun add -d @thexjs/cli`}
|
|
80
|
-
/>
|
|
81
|
-
<CodeBlock
|
|
82
|
-
label="package.json"
|
|
83
|
-
code={`{
|
|
84
|
-
"scripts": {
|
|
85
|
-
"dev": "x dev",
|
|
86
|
-
"build": "x build",
|
|
87
|
-
"start": "x start"
|
|
88
|
-
}
|
|
89
|
-
}`}
|
|
90
|
-
/>
|
|
91
|
-
<p className="mt-4 text-muted-foreground">
|
|
92
|
-
Create <span className="text-foreground">x.config.ts</span> at the project root:
|
|
93
|
-
</p>
|
|
94
|
-
<CodeBlock
|
|
95
|
-
label="x.config.ts"
|
|
96
|
-
code={`import { defineConfig } from "@thexjs/core";
|
|
97
|
-
|
|
98
|
-
export default defineConfig({
|
|
99
|
-
pagesDir: "./src/pages",
|
|
100
|
-
port: 3000,
|
|
101
|
-
});`}
|
|
102
|
-
/>
|
|
103
|
-
|
|
104
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Optional: environment validation</h2>
|
|
105
|
-
<p className="mt-3 text-muted-foreground">
|
|
106
|
-
Add <span className="text-foreground">@thexjs/env</span> when you want typed, validated
|
|
107
|
-
environment variables:
|
|
108
|
-
</p>
|
|
109
|
-
<CodeBlock label="terminal" lang="bash" code="bun add @thexjs/env" />
|
|
110
|
-
<p className="mt-4 text-muted-foreground">
|
|
111
|
-
See the{" "}
|
|
112
|
-
<a href="/docs/packages/env" className="text-primary underline underline-offset-2">
|
|
113
|
-
@thexjs/env docs
|
|
114
|
-
</a>{" "}
|
|
115
|
-
for the full API.
|
|
116
|
-
</p>
|
|
117
|
-
|
|
118
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Verify the install</h2>
|
|
119
|
-
<CodeBlock
|
|
120
|
-
label="terminal"
|
|
121
|
-
lang="bash"
|
|
122
|
-
code={`x dev
|
|
123
|
-
compiling Tailwind CSS...
|
|
124
|
-
dev server running at http://localhost:3000`}
|
|
125
|
-
/>
|
|
126
|
-
|
|
127
|
-
<div className="mt-16 flex flex-wrap gap-6 border-t border-border pt-8">
|
|
128
|
-
<a
|
|
129
|
-
href="/docs/getting-started"
|
|
130
|
-
className="inline-flex items-center gap-1 text-sm font-medium text-primary transition-colors hover:text-primary/80"
|
|
131
|
-
>
|
|
132
|
-
Getting started <ArrowRight className="h-3.5 w-3.5" />
|
|
133
|
-
</a>
|
|
134
|
-
<a
|
|
135
|
-
href="/docs"
|
|
136
|
-
className="inline-flex items-center gap-1 text-sm text-muted-foreground transition-colors hover:text-foreground"
|
|
137
|
-
>
|
|
138
|
-
<ArrowRight className="h-3.5 w-3.5 rotate-180" /> Back to docs
|
|
139
|
-
</a>
|
|
140
|
-
</div>
|
|
141
|
-
</div>
|
|
142
|
-
);
|
|
143
|
-
}
|
|
@@ -1,114 +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 const mode = "static";
|
|
6
|
-
|
|
7
|
-
export default function DocPage(_props: RouteProps) {
|
|
8
|
-
return (
|
|
9
|
-
<div>
|
|
10
|
-
<p className="text-xs font-semibold uppercase tracking-[0.2em] text-primary">Introduction</p>
|
|
11
|
-
<h1 className="mt-4 text-3xl font-bold tracking-tight sm:text-4xl">What is x?</h1>
|
|
12
|
-
<p className="mt-4 text-lg text-muted-foreground">
|
|
13
|
-
x is a full-stack React framework built on{" "}
|
|
14
|
-
<a href="https://bun.sh" className="text-primary underline underline-offset-2">
|
|
15
|
-
Bun
|
|
16
|
-
</a>
|
|
17
|
-
. File-based routing, SSR, static generation, API routes, server functions, islands, and a
|
|
18
|
-
content layer — all in one process, zero orchestration.
|
|
19
|
-
</p>
|
|
20
|
-
|
|
21
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Why x exists</h2>
|
|
22
|
-
<p className="mt-3 text-muted-foreground">
|
|
23
|
-
Most stacks split concerns across multiple tools: a bundler, a server, a static host, a
|
|
24
|
-
separate API layer. x keeps everything in one Bun process. Drop a file in{" "}
|
|
25
|
-
<span className="text-foreground">src/pages</span>, get a route. Mark a page{" "}
|
|
26
|
-
<span className="text-foreground">static</span> and it prerenders at build time. Leave it as
|
|
27
|
-
server mode and it renders per request. API routes and server functions live alongside your
|
|
28
|
-
pages — same types, same runtime.
|
|
29
|
-
</p>
|
|
30
|
-
|
|
31
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">The package ecosystem</h2>
|
|
32
|
-
<p className="mt-3 text-muted-foreground">
|
|
33
|
-
x ships as three focused npm packages. You typically install{" "}
|
|
34
|
-
<span className="text-foreground">@thexjs/cli</span> and{" "}
|
|
35
|
-
<span className="text-foreground">@thexjs/core</span> through the project scaffolder; add{" "}
|
|
36
|
-
<span className="text-foreground">@thexjs/env</span> when you need validated environment
|
|
37
|
-
variables.
|
|
38
|
-
</p>
|
|
39
|
-
<div className="mt-6 space-y-3">
|
|
40
|
-
{[
|
|
41
|
-
{
|
|
42
|
-
name: "@thexjs/core",
|
|
43
|
-
href: "/docs/packages/core",
|
|
44
|
-
desc: "Rendering engine — routing, SSR/SSG, islands, server functions, content, data layer.",
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
name: "@thexjs/cli",
|
|
48
|
-
href: "/docs/packages/cli",
|
|
49
|
-
desc: "The x command — dev server, production build, and start.",
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: "@thexjs/env",
|
|
53
|
-
href: "/docs/packages/env",
|
|
54
|
-
desc: "Type-safe environment variable validation with fail-fast errors.",
|
|
55
|
-
},
|
|
56
|
-
].map((pkg) => (
|
|
57
|
-
<a
|
|
58
|
-
key={pkg.name}
|
|
59
|
-
href={pkg.href}
|
|
60
|
-
className="block rounded-xl border border-border bg-card p-5 transition-colors hover:border-primary/30 hover:bg-card/80"
|
|
61
|
-
>
|
|
62
|
-
<p className="font-mono text-sm font-semibold text-primary">{pkg.name}</p>
|
|
63
|
-
<p className="mt-1 text-sm text-muted-foreground">{pkg.desc}</p>
|
|
64
|
-
</a>
|
|
65
|
-
))}
|
|
66
|
-
</div>
|
|
67
|
-
|
|
68
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">A minimal page</h2>
|
|
69
|
-
<p className="mt-3 text-muted-foreground">
|
|
70
|
-
Every x app starts with file-based routes. Here is the simplest possible page:
|
|
71
|
-
</p>
|
|
72
|
-
<CodeBlock
|
|
73
|
-
label="src/pages/index.tsx"
|
|
74
|
-
code={`import type { RouteProps } from "@thexjs/core";
|
|
75
|
-
|
|
76
|
-
export const mode = "static";
|
|
77
|
-
|
|
78
|
-
export default function HomePage({}: RouteProps) {
|
|
79
|
-
return <h1>Hello from x</h1>;
|
|
80
|
-
}`}
|
|
81
|
-
/>
|
|
82
|
-
<p className="mt-4 text-muted-foreground">
|
|
83
|
-
Run <span className="text-foreground">x dev</span> and visit{" "}
|
|
84
|
-
<span className="text-foreground">http://localhost:3000</span>. That is the entire loop.
|
|
85
|
-
</p>
|
|
86
|
-
|
|
87
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Static vs server</h2>
|
|
88
|
-
<p className="mt-3 text-muted-foreground">
|
|
89
|
-
Pages default to server-rendered (SSR). Opt into build-time prerendering per page:
|
|
90
|
-
</p>
|
|
91
|
-
<CodeBlock label="route mode" code={`export const mode: "static" | "server" = "static";`} />
|
|
92
|
-
<p className="mt-4 text-muted-foreground">
|
|
93
|
-
Static pages ship as plain HTML in <span className="text-foreground">.x/client/</span> —
|
|
94
|
-
deployable to any static host. Server pages need a running Bun process via{" "}
|
|
95
|
-
<span className="text-foreground">x start</span>.
|
|
96
|
-
</p>
|
|
97
|
-
|
|
98
|
-
<div className="mt-16 flex flex-wrap gap-6 border-t border-border pt-8">
|
|
99
|
-
<a
|
|
100
|
-
href="/docs/installation"
|
|
101
|
-
className="inline-flex items-center gap-1 text-sm font-medium text-primary transition-colors hover:text-primary/80"
|
|
102
|
-
>
|
|
103
|
-
Install x <ArrowRight className="h-3.5 w-3.5" />
|
|
104
|
-
</a>
|
|
105
|
-
<a
|
|
106
|
-
href="/docs"
|
|
107
|
-
className="inline-flex items-center gap-1 text-sm text-muted-foreground transition-colors hover:text-foreground"
|
|
108
|
-
>
|
|
109
|
-
<ArrowRight className="h-3.5 w-3.5 rotate-180" /> Back to docs
|
|
110
|
-
</a>
|
|
111
|
-
</div>
|
|
112
|
-
</div>
|
|
113
|
-
);
|
|
114
|
-
}
|
|
@@ -1,114 +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">Layouts</p>
|
|
9
|
-
<h1 className="mt-4 text-3xl font-bold tracking-tight sm:text-4xl">Layouts</h1>
|
|
10
|
-
<p className="mt-4 text-lg text-muted-foreground">
|
|
11
|
-
Layouts wrap your pages with shared UI. x supports nested layouts via a dedicated layouts
|
|
12
|
-
directory and the <span className="text-foreground">_layout.tsx</span> convention.
|
|
13
|
-
</p>
|
|
14
|
-
|
|
15
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Layouts directory</h2>
|
|
16
|
-
<p className="mt-3 text-muted-foreground">
|
|
17
|
-
Configure a layouts directory in <span className="text-foreground">x.config.ts</span>.
|
|
18
|
-
Layouts follow the same file-tree hierarchy as pages.
|
|
19
|
-
</p>
|
|
20
|
-
<CodeBlock
|
|
21
|
-
label="x.config.ts"
|
|
22
|
-
code={`import { defineConfig } from "@thexjs/core";
|
|
23
|
-
|
|
24
|
-
export default defineConfig({
|
|
25
|
-
pagesDir: "src/pages",
|
|
26
|
-
layoutsDir: "src/layouts",
|
|
27
|
-
});`}
|
|
28
|
-
/>
|
|
29
|
-
|
|
30
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Root layout</h2>
|
|
31
|
-
<p className="mt-3 text-muted-foreground">
|
|
32
|
-
The root layout wraps every page in your app. Create{" "}
|
|
33
|
-
<span className="text-foreground">src/layouts/main.tsx</span> to add a header, footer, or
|
|
34
|
-
global styling.
|
|
35
|
-
</p>
|
|
36
|
-
<CodeBlock
|
|
37
|
-
label="src/layouts/main.tsx"
|
|
38
|
-
code={`import type { ReactNode } from "react";
|
|
39
|
-
|
|
40
|
-
export default function RootLayout({ children }: { children: ReactNode }) {
|
|
41
|
-
return (
|
|
42
|
-
<div className="flex min-h-screen flex-col bg-background">
|
|
43
|
-
<header className="border-b border-border p-4">
|
|
44
|
-
<a href="/docs" className="text-lg font-bold">My App</a>
|
|
45
|
-
</header>
|
|
46
|
-
<main className="flex-1">{children}</main>
|
|
47
|
-
<footer className="border-t border-border p-4 text-center text-sm text-muted-foreground">
|
|
48
|
-
© 2026 My App
|
|
49
|
-
</footer>
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
}`}
|
|
53
|
-
/>
|
|
54
|
-
|
|
55
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Nested layouts with _layout.tsx</h2>
|
|
56
|
-
<p className="mt-3 text-muted-foreground">
|
|
57
|
-
Place a <span className="text-foreground">_layout.tsx</span> file inside a pages folder to
|
|
58
|
-
create a nested layout. All pages in that folder (and subfolders) inherit it.
|
|
59
|
-
</p>
|
|
60
|
-
<CodeBlock
|
|
61
|
-
label="file tree"
|
|
62
|
-
lang="tree"
|
|
63
|
-
code={`pages/
|
|
64
|
-
_layout.tsx -> root layout
|
|
65
|
-
index.tsx
|
|
66
|
-
blog/
|
|
67
|
-
_layout.tsx -> nested layout for /blog/*
|
|
68
|
-
index.tsx
|
|
69
|
-
[slug].tsx`}
|
|
70
|
-
/>
|
|
71
|
-
|
|
72
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Nested blog layout example</h2>
|
|
73
|
-
<p className="mt-3 text-muted-foreground">
|
|
74
|
-
A nested layout can add a sidebar, breadcrumbs, or section-specific navigation.
|
|
75
|
-
</p>
|
|
76
|
-
<CodeBlock
|
|
77
|
-
label="src/pages/blog/_layout.tsx"
|
|
78
|
-
code={`import type { ReactNode } from "react";
|
|
79
|
-
|
|
80
|
-
export default function BlogLayout({ children }: { children: ReactNode }) {
|
|
81
|
-
return (
|
|
82
|
-
<div className="flex gap-8">
|
|
83
|
-
<aside className="w-64 shrink-0">
|
|
84
|
-
<nav className="space-y-2">
|
|
85
|
-
<a href="/blog" className="block font-semibold">All posts</a>
|
|
86
|
-
<a href="/blog/category/react" className="block text-muted-foreground hover:text-foreground">React</a>
|
|
87
|
-
<a href="/blog/category/bun" className="block text-muted-foreground hover:text-foreground">Bun</a>
|
|
88
|
-
</nav>
|
|
89
|
-
</aside>
|
|
90
|
-
<div className="min-w-0 flex-1">{children}</div>
|
|
91
|
-
</div>
|
|
92
|
-
);
|
|
93
|
-
}`}
|
|
94
|
-
/>
|
|
95
|
-
|
|
96
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Layout chain</h2>
|
|
97
|
-
<p className="mt-3 text-muted-foreground">
|
|
98
|
-
Layouts nest hierarchically. A page under{" "}
|
|
99
|
-
<span className="text-foreground">pages/blog/[slug].tsx</span> would be wrapped by{" "}
|
|
100
|
-
<span className="text-foreground">blog/_layout.tsx</span> and then the root layout. The
|
|
101
|
-
chain is resolved automatically based on the page's file path.
|
|
102
|
-
</p>
|
|
103
|
-
|
|
104
|
-
<div className="mt-16 border-t border-border pt-8">
|
|
105
|
-
<a
|
|
106
|
-
href="/docs"
|
|
107
|
-
className="inline-flex items-center gap-1 text-sm text-muted-foreground transition-colors hover:text-foreground"
|
|
108
|
-
>
|
|
109
|
-
<ArrowRight className="h-3.5 w-3.5 rotate-180" /> Back to docs
|
|
110
|
-
</a>
|
|
111
|
-
</div>
|
|
112
|
-
</div>
|
|
113
|
-
);
|
|
114
|
-
}
|
|
@@ -1,124 +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">Middleware</p>
|
|
9
|
-
<h1 className="mt-4 text-3xl font-bold tracking-tight sm:text-4xl">Middleware</h1>
|
|
10
|
-
<p className="mt-4 text-lg text-muted-foreground">
|
|
11
|
-
Route-level middleware lets you intercept requests before they reach your page or API
|
|
12
|
-
handler. Use it for authentication, redirects, logging, and validation.
|
|
13
|
-
</p>
|
|
14
|
-
|
|
15
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">The _middleware.ts convention</h2>
|
|
16
|
-
<p className="mt-3 text-muted-foreground">
|
|
17
|
-
Place a <span className="text-foreground">_middleware.ts</span> file in any route directory.
|
|
18
|
-
It runs for all routes in that directory and its subdirectories.
|
|
19
|
-
</p>
|
|
20
|
-
<CodeBlock
|
|
21
|
-
label="file tree"
|
|
22
|
-
lang="tree"
|
|
23
|
-
code={`pages/
|
|
24
|
-
_middleware.ts -> runs for all routes
|
|
25
|
-
index.tsx
|
|
26
|
-
dashboard/
|
|
27
|
-
_middleware.ts -> runs only for /dashboard/*
|
|
28
|
-
settings.tsx
|
|
29
|
-
profile.tsx
|
|
30
|
-
admin/
|
|
31
|
-
_middleware.ts -> auth check for /admin/*
|
|
32
|
-
index.tsx`}
|
|
33
|
-
/>
|
|
34
|
-
|
|
35
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Middleware context</h2>
|
|
36
|
-
<p className="mt-3 text-muted-foreground">
|
|
37
|
-
A middleware function receives an object with{" "}
|
|
38
|
-
<span className="text-foreground">params</span> (dynamic route params),{" "}
|
|
39
|
-
<span className="text-foreground">request</span> (the original Request), and a{" "}
|
|
40
|
-
<span className="text-foreground">next</span> function to continue the chain.
|
|
41
|
-
</p>
|
|
42
|
-
<CodeBlock
|
|
43
|
-
label="src/pages/_middleware.ts"
|
|
44
|
-
code={`import type { MiddlewareContext, MiddlewareNext } from "@thexjs/core";
|
|
45
|
-
|
|
46
|
-
export async function middleware(ctx: MiddlewareContext, next: MiddlewareNext) {
|
|
47
|
-
console.log(\`[${"$"}{ctx.request.method}] ${"$"}{ctx.request.url}\`);
|
|
48
|
-
return next(ctx);
|
|
49
|
-
}`}
|
|
50
|
-
/>
|
|
51
|
-
|
|
52
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Auth middleware example</h2>
|
|
53
|
-
<p className="mt-3 text-muted-foreground">
|
|
54
|
-
A common use case is checking for an auth cookie and redirecting unauthenticated users.
|
|
55
|
-
</p>
|
|
56
|
-
<CodeBlock
|
|
57
|
-
label="src/pages/dashboard/_middleware.ts"
|
|
58
|
-
code={`import type { MiddlewareContext, MiddlewareNext } from "@thexjs/core";
|
|
59
|
-
|
|
60
|
-
export async function middleware(ctx: MiddlewareContext, next: MiddlewareNext) {
|
|
61
|
-
const session = ctx.request.cookies.get("session");
|
|
62
|
-
|
|
63
|
-
if (!session) {
|
|
64
|
-
return new Response(null, {
|
|
65
|
-
status: 302,
|
|
66
|
-
headers: { Location: "/login" },
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const user = await validateSession(session);
|
|
71
|
-
if (!user) {
|
|
72
|
-
return new Response(null, {
|
|
73
|
-
status: 302,
|
|
74
|
-
headers: { Location: "/login" },
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
ctx.params.user = user;
|
|
79
|
-
return next(ctx);
|
|
80
|
-
}`}
|
|
81
|
-
/>
|
|
82
|
-
|
|
83
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">MiddlewareNext</h2>
|
|
84
|
-
<p className="mt-3 text-muted-foreground">
|
|
85
|
-
Call <span className="text-foreground">next(ctx)</span> to pass control to the next
|
|
86
|
-
middleware or the route handler. You can modify{" "}
|
|
87
|
-
<span className="text-foreground">ctx.params</span> to enrich the request context for
|
|
88
|
-
downstream handlers.
|
|
89
|
-
</p>
|
|
90
|
-
|
|
91
|
-
<h2 className="mt-12 text-xl font-bold tracking-tight">Redirect patterns</h2>
|
|
92
|
-
<p className="mt-3 text-muted-foreground">
|
|
93
|
-
Return a <span className="text-foreground">Response</span> with a 302 status and a{" "}
|
|
94
|
-
<span className="text-foreground">Location</span> header to redirect. You can also return
|
|
95
|
-
JSON responses for API middleware validation errors.
|
|
96
|
-
</p>
|
|
97
|
-
<CodeBlock
|
|
98
|
-
label="redirect example"
|
|
99
|
-
code={`// Redirect to login
|
|
100
|
-
return new Response(null, {
|
|
101
|
-
status: 302,
|
|
102
|
-
headers: { Location: "/login?redirect=" + ctx.request.url },
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
// Redirect back after successful auth
|
|
106
|
-
const url = new URL(ctx.request.url);
|
|
107
|
-
const redirectTo = url.searchParams.get("redirect") || "/";
|
|
108
|
-
return new Response(null, {
|
|
109
|
-
status: 302,
|
|
110
|
-
headers: { Location: redirectTo },
|
|
111
|
-
});`}
|
|
112
|
-
/>
|
|
113
|
-
|
|
114
|
-
<div className="mt-16 border-t border-border pt-8">
|
|
115
|
-
<a
|
|
116
|
-
href="/docs"
|
|
117
|
-
className="inline-flex items-center gap-1 text-sm text-muted-foreground transition-colors hover:text-foreground"
|
|
118
|
-
>
|
|
119
|
-
<ArrowRight className="h-3.5 w-3.5 rotate-180" /> Back to docs
|
|
120
|
-
</a>
|
|
121
|
-
</div>
|
|
122
|
-
</div>
|
|
123
|
-
);
|
|
124
|
-
}
|