Getting Started
Get started with X
Create a new X project, learn the project structure, and build your first page.
Create a project
The fastest way to start is with the project scaffolder. See Installation for prerequisites and template options. Quick version:
terminal
bun create thexjs-app@latest my-appcd my-appbun run dev
Press Enter at the template prompt to use default (recommended), a single home page. Your app will be running at http://localhost:3000.
Manual setup
If you prefer to set up manually, create a directory and add X:
terminal
mkdir my-app && cd my-appbun init -ybun add @thexjs/corecat << EOF > x.config.tsimport { defineConfig } from "@thexjs/core";export default defineConfig({pagesDir: "src/pages",apiDir: "src/api", // optional: API routesactionsDir: "src/actions", // optional: server functions});EOF
Project structure
A typical X project looks like this:
file tree
my-app/x.config.tssrc/pages/ // File-based routesindex.tsxabout.tsx_404.tsxblog/[slug].tsxlayouts/ // Nested layoutsmain.tsxapi/ // API routeshello.tsactions/ // Server functionsgreet.tscontent/ // Markdown contentposts/hello-world.md
Your first page
Create src/pages/index.tsx with a simple component:
src/pages/index.tsx
export default function Home() { return ( <div> <h1 className="text-4xl font-bold">Hello x!</h1> <p className="text-muted-foreground">Welcome to your new app.</p> </div> );}Running the dev server
Start the development server with hot reload:
terminal
x dev[x] dev server starting...✓ dev server running at http://localhost:3000
The dev server watches your src/ directory and automatically reloads when files change.