create-thexjs-app 0.1.3 → 1.0.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 CHANGED
@@ -7,7 +7,7 @@
7
7
  <p align="center">
8
8
 
9
9
  <strong>The ultra-fast, full-stack React framework built natively for Bun.</strong>
10
- Static sites, SSR, file-based API routes, and server functions — running in a single process.
10
+ Static sites, SSR, file-based API routes, and server functions, running in a single process.
11
11
 
12
12
  </p>
13
13
 
@@ -56,7 +56,7 @@ cd my-app
56
56
  bun run dev
57
57
  ```
58
58
 
59
- When prompted for a template, press Enter to accept **default** (recommended) — a single home page to start from.
59
+ When prompted for a template, press Enter to accept **default** (recommended), a single home page to start from.
60
60
 
61
61
  Your app will be running at `http://localhost:3000`.
62
62
 
@@ -173,11 +173,12 @@ export async function loader({ params }: LoaderArgs) {
173
173
  return { title: post.title, content: post.content };
174
174
  }
175
175
 
176
- export default function BlogPost({ loaderData }: RouteProps<typeof loader>) {
176
+ export default function BlogPost({ loaderData }: RouteProps) {
177
+ const { title, content } = loaderData as { title: string; content: string };
177
178
  return (
178
179
  <article>
179
- <h1 className="text-3xl font-bold">{loaderData.title}</h1>
180
- <div>{loaderData.content}</div>
180
+ <h1 className="text-3xl font-bold">{title}</h1>
181
+ <div>{content}</div>
181
182
  </article>
182
183
  );
183
184
  }
@@ -221,7 +222,7 @@ export default function NotFound() {
221
222
 
222
223
  ## Pages & Loaders
223
224
 
224
- x supports two page modes — static prerendering and server-side rendering — both powered by loaders.
225
+ x supports two page modes: static prerendering and server-side rendering, both powered by loaders.
225
226
 
226
227
  ### Page modes
227
228
 
@@ -261,12 +262,13 @@ export async function loader({ request }: LoaderArgs) {
261
262
  return { products };
262
263
  }
263
264
 
264
- export default function Products({ loaderData }: RouteProps<typeof loader>) {
265
+ export default function Products({ loaderData }: RouteProps) {
266
+ const { products } = loaderData as { products: Array<{ id: string; name: string; price: number }> };
265
267
  return (
266
268
  <div>
267
269
  <h1 className="text-3xl font-bold">Products</h1>
268
270
  <ul className="mt-6 space-y-4">
269
- {loaderData.products.map((p: any) => (
271
+ {products.map((p) => (
270
272
  <li key={p.id} className="rounded-xl border border-border bg-card p-4">
271
273
  <h2 className="font-semibold">{p.name}</h2>
272
274
  <p className="text-sm text-muted-foreground">{p.price}</p>
@@ -289,12 +291,12 @@ export async function loader({ params }: LoaderArgs) {
289
291
  const product = await db.query(
290
292
  "SELECT * FROM products WHERE id = ?", [params.id]
291
293
  );
292
- if (!product) throw new Response(null, { status: 404 });
294
+ if (!product) return new Response(null, { status: 404 });
293
295
  return { product };
294
296
  }
295
297
 
296
- export default function ProductDetail({ loaderData }: RouteProps<typeof loader>) {
297
- const { product } = loaderData;
298
+ export default function ProductDetail({ loaderData }: RouteProps) {
299
+ const { product } = loaderData as { product: { name: string; description: string; price: number } };
298
300
  return (
299
301
  <div>
300
302
  <h1 className="text-3xl font-bold">{product.name}</h1>
@@ -307,15 +309,14 @@ export default function ProductDetail({ loaderData }: RouteProps<typeof loader>)
307
309
 
308
310
  ### RouteProps type
309
311
 
310
- The `RouteProps` type provides typed access to `loaderData`, `params`, and `request`. Pass your loader function as the type parameter for full type safety.
312
+ `RouteProps` is a plain non-generic type with `params` (a `Record<string, string>` of dynamic segments) and `loaderData` (the loader's return value). Cast loader data to its shape for inline types.
311
313
 
312
314
  ```tsx
313
315
  import type { RouteProps } from "@thexjs/core";
314
316
 
315
- export default function Page({ loaderData, params, request }: RouteProps<typeof loader>) {
316
- // loaderData has the return type of loader()
317
- // params has the dynamic segment types
318
- // request is the standard Request object
317
+ export default function ProductDetail({ loaderData }: RouteProps) {
318
+ const { product } = loaderData as { product: { name: string; price: number } };
319
+ return <h1>{product.name}</h1>;
319
320
  }
320
321
  ```
321
322
 
@@ -409,43 +410,37 @@ Build REST endpoints alongside your frontend pages. API routes live in `src/api/
409
410
 
410
411
  Like pages, API routes use the file system. A file at `src/api/hello.ts` becomes `/api/hello`.
411
412
 
412
- ```tsx
413
- import type { ApiHandler } from "@thexjs/core";
414
-
415
- export const GET: ApiHandler = ({ request }) => {
413
+ ```ts
414
+ export function GET(req: Request) {
416
415
  return Response.json({ message: "Hello from x!" });
417
- };
416
+ }
418
417
  ```
419
418
 
420
419
  ### Request & response
421
420
 
422
- Each exported HTTP method receives the request and returns a standard `Response` object. Dynamic segments work the same as pages: `api/users/[id].ts` → `/api/users/:id`.
421
+ Each exported HTTP method is a plain `export async function GET(req: Request)` that receives the standard fetch `Request` and returns a `Response`. Dynamic segments work the same as pages: `api/users/[id].ts` → `/api/users/:id`.
423
422
 
424
423
  ```tsx
425
- import type { ApiHandler } from "@thexjs/core";
426
-
427
- export const GET: ApiHandler = async ({ request }) => {
428
- const users = await db.query("SELECT * FROM users");
424
+ export async function GET(req: Request) {
425
+ const users = await db.query("SELECT * FROM users").all();
429
426
  return Response.json(users);
430
- };
427
+ }
431
428
 
432
- export const POST: ApiHandler = async ({ request }) => {
433
- const body = await request.json();
429
+ export async function POST(req: Request) {
430
+ const body = await req.json();
434
431
  const result = await db.query(
435
432
  "INSERT INTO users (name, email) VALUES (?, ?) RETURNING *",
436
433
  [body.name, body.email]
437
434
  );
438
435
  return Response.json(result, { status: 201 });
439
- };
436
+ }
440
437
  ```
441
438
 
442
439
  ### POST endpoint example
443
440
 
444
441
  ```tsx
445
- import type { ApiHandler } from "@thexjs/core";
446
-
447
- export const POST: ApiHandler = async ({ request }) => {
448
- const form = await request.formData();
442
+ export async function POST(req: Request) {
443
+ const form = await req.formData();
449
444
  const email = form.get("email");
450
445
  const message = form.get("message");
451
446
 
@@ -458,12 +453,12 @@ export const POST: ApiHandler = async ({ request }) => {
458
453
 
459
454
  await sendEmail({ email, message });
460
455
  return Response.json({ success: true });
461
- };
456
+ }
462
457
  ```
463
458
 
464
459
  ### API route tree
465
460
 
466
- API routes support the same file-tree conventions as pages — nested folders, dynamic segments, and index files.
461
+ API routes support the same file-tree conventions as pages: nested folders, dynamic segments, and index files.
467
462
 
468
463
  ```
469
464
  src/api/
@@ -549,7 +544,7 @@ export default function GreetForm() {
549
544
 
550
545
  ### Server functions from loaders
551
546
 
552
- You can also import and call server functions directly in loaders — no HTTP needed since they share the same process.
547
+ You can also import and call server functions directly in loaders; no HTTP needed since they share the same process.
553
548
 
554
549
  ```tsx
555
550
  import type { RouteProps, LoaderArgs } from "@thexjs/core";
@@ -560,7 +555,7 @@ export async function loader({ request }: LoaderArgs) {
560
555
  return { data };
561
556
  }
562
557
 
563
- export default function Dashboard({ loaderData }: RouteProps<typeof loader>) {
558
+ export default function Dashboard({ loaderData }: RouteProps) {
564
559
  return <div>...</div>;
565
560
  }
566
561
  ```
@@ -620,22 +615,25 @@ import type { RouteProps, LoaderArgs } from "@thexjs/core";
620
615
  import { scanContent, renderMarkdown } from "@thexjs/core";
621
616
 
622
617
  export async function loader({ params }: LoaderArgs) {
623
- const posts = await scanContent("posts");
618
+ const posts = scanContent("posts");
624
619
  const post = posts.find((p) => p.slug === params.slug);
625
- if (!post) throw new Response(null, { status: 404 });
626
- const html = await renderMarkdown(post.body);
620
+ if (!post) return new Response(null, { status: 404 });
621
+ const html = renderMarkdown(post.body);
627
622
  return { post: { ...post, html } };
628
623
  }
629
624
 
630
- export default function BlogPost({ loaderData }: RouteProps<typeof loader>) {
625
+ export default function BlogPost({ loaderData }: RouteProps) {
626
+ const { post } = loaderData as {
627
+ post: { frontmatter: Record<string, unknown>; html: string; date: string; author: string; tags?: string[] };
628
+ };
631
629
  return (
632
630
  <article className="prose max-w-none">
633
- <h1 className="text-4xl font-bold">{loaderData.post.title}</h1>
631
+ <h1 className="text-4xl font-bold">{String(post.frontmatter.title)}</h1>
634
632
  <p className="text-sm text-muted-foreground">
635
- {loaderData.post.date} &mdash; {loaderData.post.author}
633
+ {post.date} &mdash; {post.author}
636
634
  </p>
637
635
  <div className="mt-6 flex gap-2">
638
- {loaderData.post.tags?.map((tag: string) => (
636
+ {post.tags?.map((tag) => (
639
637
  <span key={tag} className="rounded-full bg-primary/10 px-3 py-1 text-xs text-primary">
640
638
  {tag}
641
639
  </span>
@@ -643,7 +641,7 @@ export default function BlogPost({ loaderData }: RouteProps<typeof loader>) {
643
641
  </div>
644
642
  <div
645
643
  className="mt-8 leading-relaxed"
646
- dangerouslySetInnerHTML={{ __html: loaderData.post.html }}
644
+ dangerouslySetInnerHTML={{ __html: post.html }}
647
645
  />
648
646
  </article>
649
647
  );
@@ -652,11 +650,11 @@ export default function BlogPost({ loaderData }: RouteProps<typeof loader>) {
652
650
 
653
651
  ### scanContent API
654
652
 
655
- `scanContent(directory)` scans a subdirectory of your content folder and returns an array of content entries. Each entry includes `slug`, `frontmatter`, and `content`.
653
+ `scanContent(directory)` scans a subdirectory of your content folder (synchronously) and returns an array of content entries. Each entry includes `filePath`, `routePath`, `slug`, `frontmatter`, and `body`.
656
654
 
657
655
  ### renderMarkdown API
658
656
 
659
- `renderMarkdown(markdownString)` converts markdown to an HTML string. It supports syntax highlighting via Shiki and handles all standard markdown features.
657
+ `renderMarkdown(markdownString)` converts Markdown to an HTML string. It's a lightweight, dependency-free renderer (headings, paragraphs, lists, links, inline code, code blocks, bold/italic, blockquotes) that HTML-escapes content by default.
660
658
 
661
659
  ---
662
660
 
@@ -690,7 +688,7 @@ import type { MiddlewareContext, MiddlewareNext } from "@thexjs/core";
690
688
 
691
689
  export async function middleware(ctx: MiddlewareContext, next: MiddlewareNext) {
692
690
  console.log(`[${ctx.request.method}] ${ctx.request.url}`);
693
- return next(ctx);
691
+ return next();
694
692
  }
695
693
  ```
696
694
 
@@ -700,7 +698,7 @@ export async function middleware(ctx: MiddlewareContext, next: MiddlewareNext) {
700
698
  import type { MiddlewareContext, MiddlewareNext } from "@thexjs/core";
701
699
 
702
700
  export async function middleware(ctx: MiddlewareContext, next: MiddlewareNext) {
703
- const session = ctx.request.cookies.get("session");
701
+ const session = ctx.request.headers.get("cookie");
704
702
 
705
703
  if (!session) {
706
704
  return new Response(null, {
@@ -717,14 +715,13 @@ export async function middleware(ctx: MiddlewareContext, next: MiddlewareNext) {
717
715
  });
718
716
  }
719
717
 
720
- ctx.params.user = user;
721
- return next(ctx);
718
+ return next();
722
719
  }
723
720
  ```
724
721
 
725
722
  ### MiddlewareNext
726
723
 
727
- Call `next(ctx)` to pass control to the next middleware or the route handler. You can modify `ctx.params` to enrich the request context for downstream handlers.
724
+ Call `next()` (no arguments) to pass control to the next middleware or the route handler. Any mutations to `ctx.params` you make before the call flow through to downstream handlers. Middleware applies to page routes only, not API routes.
728
725
 
729
726
  ### Redirect patterns
730
727
 
@@ -755,44 +752,23 @@ x provides built-in SQLite and PostgreSQL integrations. Connect to a database, r
755
752
  Use `connectSQLite` to connect to a local SQLite database file. SQLite requires zero configuration and is perfect for development and single-server deployments.
756
753
 
757
754
  ```ts
758
- import { connectSQLite, runSQLiteMigrations } from "@thexjs/core";
759
-
760
- const db = connectSQLite("data/app.db");
761
-
762
- await runSQLiteMigrations(db, [
763
- {
764
- version: 1,
765
- sql: `
766
- CREATE TABLE IF NOT EXISTS users (
767
- id INTEGER PRIMARY KEY AUTOINCREMENT,
768
- name TEXT NOT NULL,
769
- email TEXT UNIQUE NOT NULL,
770
- created_at TEXT DEFAULT (datetime('now'))
771
- )
772
- `,
773
- },
774
- {
775
- version: 2,
776
- sql: `
777
- CREATE TABLE IF NOT EXISTS posts (
778
- id INTEGER PRIMARY KEY AUTOINCREMENT,
779
- user_id INTEGER REFERENCES users(id),
780
- title TEXT NOT NULL,
781
- body TEXT,
782
- created_at TEXT DEFAULT (datetime('now'))
783
- )
784
- `,
785
- },
786
- ]);
755
+ import { connectSQLite, runSQLiteMigrations } from "@thexjs/core/data";
756
+
757
+ const db = connectSQLite({ path: "data/app.db" });
758
+
759
+ // Points at a directory of .sql files (e.g. data/migrations/001_create_users.sql)
760
+ await runSQLiteMigrations(db, "data/migrations");
787
761
 
788
762
  export { db };
789
763
  ```
790
764
 
765
+ `runSQLiteMigrations` runs each `.sql` file in the directory in sorted order, tracking them in a `_x_migrations` table so each runs only once. It returns `{ applied, skipped }`.
766
+
791
767
  ### Querying SQLite
792
768
 
793
769
  The database object supports prepared statements with `query` and `execute` methods.
794
770
 
795
- ```tsx
771
+ ```ts
796
772
  import type { RouteProps, LoaderArgs } from "@thexjs/core";
797
773
  import { db } from "../lib/db";
798
774
 
@@ -803,12 +779,13 @@ export async function loader({}: LoaderArgs) {
803
779
  return { users };
804
780
  }
805
781
 
806
- export default function Users({ loaderData }: RouteProps<typeof loader>) {
782
+ export default function Users({ loaderData }: RouteProps) {
783
+ const { users } = loaderData as { users: Array<{ id: string; name: string; email: string }> };
807
784
  return (
808
785
  <div>
809
786
  <h1 className="text-3xl font-bold">Users</h1>
810
787
  <ul className="mt-6 space-y-3">
811
- {loaderData.users.map((u: any) => (
788
+ {users.map((u) => (
812
789
  <li key={u.id} className="rounded-xl border border-border bg-card p-4">
813
790
  <p className="font-semibold">{u.name}</p>
814
791
  <p className="text-sm text-muted-foreground">{u.email}</p>
@@ -825,90 +802,43 @@ export default function Users({ loaderData }: RouteProps<typeof loader>) {
825
802
  For production deployments, use `connectPostgres` with a connection string. PostgreSQL provides concurrent access, connection pooling, and is suitable for multi-server deployments.
826
803
 
827
804
  ```ts
828
- import { connectPostgres, runPostgresMigrations } from "@thexjs/core";
805
+ import { connectPostgres, runPostgresMigrations } from "@thexjs/core/data";
829
806
 
830
807
  const db = connectPostgres({
831
- connectionString: process.env.DATABASE_URL,
808
+ url: process.env.DATABASE_URL,
832
809
  max: 20, // connection pool size
833
810
  });
834
811
 
835
- await runPostgresMigrations(db, [
836
- {
837
- version: 1,
838
- sql: `
839
- CREATE TABLE IF NOT EXISTS users (
840
- id SERIAL PRIMARY KEY,
841
- name VARCHAR(255) NOT NULL,
842
- email VARCHAR(255) UNIQUE NOT NULL,
843
- created_at TIMESTAMPTZ DEFAULT NOW()
844
- )
845
- `,
846
- },
847
- ]);
812
+ await runPostgresMigrations(db, "data/migrations");
848
813
 
849
814
  export { db };
850
815
  ```
851
816
 
852
817
  ### Migration API
853
818
 
854
- Both `runSQLiteMigrations` and `runPostgresMigrations` take an array of migration objects. Each migration has a `version` number (incrementing) and `sql` string. Migrations are tracked and only run once.
819
+ Both `runSQLiteMigrations` and `runPostgresMigrations` take a database connection and a **directory of `.sql` files**. The files run in sorted order and are tracked in a `_x_migrations` table, so each runs only once. They return `{ applied, skipped }`.
855
820
 
856
821
  ---
857
822
 
858
823
  ## Build & Deploy
859
824
 
860
- x produces optimized production builds with static HTML export, a server entry point, and content collection rendering — all in a single command.
861
-
862
- ### Build command
825
+ x produces optimized production builds with static HTML export, a server entry point, and content collection rendering, all in a single command.
863
826
 
864
- Run `x build` to produce a production build. The build output goes to a `.x/` directory.
865
-
866
- ```bash
867
- x build
868
- [x] resolving routes...
869
- [x] found 12 routes
870
- [x] building static pages...
871
- [x] building server bundle...
872
- [x] rendering content collections...
873
- [x] build complete in 1.2s
874
- ```
875
-
876
- ### Output structure
877
-
878
- The `.x/` directory contains everything needed to deploy — static files, server bundle, and assets.
827
+ Build with `x build --outDir <dir>` (default `.x`). Output:
879
828
 
880
829
  ```
881
830
  .x/
882
- client/ # Client-side assets
883
- assets/
884
- *.js # Bundled JS
885
- *.css # Extracted CSS
886
- server/ # Server entry point
887
- index.js # Bun server bundle
888
- static/ # Prerendered HTML pages
831
+ client/ # Prerendered static HTML + assets (deployable as a static site)
889
832
  index.html
890
833
  about/index.html
891
- blog/
892
- hello-world/index.html
893
- x.json # Build manifest
834
+ styles.css
835
+ public/ # your public/ assets copied alongside
836
+ _islands/ # per-page island hydration bundles
837
+ server/
838
+ index.ts # Bun server entry for server-mode pages + API routes
894
839
  ```
895
840
 
896
- ### Static page export
897
-
898
- Pages with `mode = "static"` are exported as HTML files in `.x/static/`. Each page is fully rendered at build time, including its loader output.
899
-
900
- ### Server entry
901
-
902
- Server-rendered pages are bundled into `.x/server/index.js`. This file contains all server routes, API handlers, server functions, and middleware.
903
-
904
- ### Production server
905
-
906
- Use `x start` to run the production server. It serves static files from `.x/static/` and handles dynamic routes via the server bundle.
907
-
908
- ```bash
909
- x start
910
- [x] production server running at http://localhost:3000
911
- ```
841
+ Static pages are exported as HTML under `client/`. Server-rendered pages and API routes are covered by `server/index.ts`, run with `x start`. `x build --adapter vercel` emits a `.vercel/output` tree instead for Vercel.
912
842
 
913
843
  ### Docker deployment
914
844
 
@@ -972,9 +902,9 @@ export default defineConfig({
972
902
  |--------------|----------|---------------|------------------------------------|
973
903
  | `pagesDir` | `string` | `"src/pages"` | File-based page routes |
974
904
  | `layoutsDir` | `string` | `"src/layouts"` | Root layout directory |
975
- | `apiDir` | `string` | `"src/api"` | File-based API routes |
976
- | `actionsDir` | `string` | `"src/actions"` | Server functions |
977
- | `contentDir` | `string` | `"content"` | Markdown content collections |
905
+ | `apiDir` | `string` | *(none)* | File-based API routes |
906
+ | `actionsDir` | `string` | *(auto-detected)* | Server functions |
907
+ | `contentDir` | `string` | *(auto-detected)* | Markdown content collections |
978
908
  | `port` | `number` | `3000` | Dev server port |
979
909
  | `routesDir` | `string` | `undefined` | Legacy routes directory |
980
910
 
package/dist/index.js CHANGED
@@ -180,6 +180,7 @@ function printBanner() {
180
180
  function printTemplateList() {
181
181
  for (const name of TEMPLATE_NAMES) {
182
182
  const meta = TEMPLATES[name];
183
+ if (!meta) continue;
183
184
  const tag = meta.recommended ? dimText(" (recommended)") : "";
184
185
  console.log(` ${name.padEnd(8)} ${meta.description}${tag}`);
185
186
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-thexjs-app",
3
- "version": "0.1.3",
3
+ "version": "1.0.0",
4
4
  "description": "Scaffold a new x framework app (npm create thexjs-app@latest).",
5
5
  "keywords": [
6
6
  "react",
@@ -1,6 +1,11 @@
1
+ import type { Database } from "bun:sqlite";
2
+ // DEMO ONLY: hardcoded admin/admin credentials, plaintext password comparison,
3
+ // no session expiry. This auth is a placeholder for demos — replace with real
4
+ // credential storage (hashed passwords) before shipping anything production.
1
5
  import { randomUUID } from "node:crypto";
2
- import { join } from "node:path";
3
- import { connectSQLite, runSQLiteMigrations } from "@thexjs/core";
6
+ import { mkdirSync } from "node:fs";
7
+ import { dirname, join } from "node:path";
8
+ import { connectSQLite, runSQLiteMigrations } from "@thexjs/core/data";
4
9
 
5
10
  const SESSION_COOKIE = "x_session";
6
11
  const SESSION_MAX_AGE = 60 * 60 * 24 * 7;
@@ -12,9 +17,13 @@ export interface Session {
12
17
  username: string;
13
18
  }
14
19
 
15
- function getDb() {
20
+ let db: Database | null = null;
21
+
22
+ function getDb(): Database {
23
+ if (db) return db;
16
24
  const dbPath = join(import.meta.dir, "..", "..", "data", "dev.db");
17
- const db = connectSQLite({ path: dbPath });
25
+ mkdirSync(dirname(dbPath), { recursive: true });
26
+ db = connectSQLite({ path: dbPath });
18
27
  runSQLiteMigrations(db, join(import.meta.dir, "migrations"));
19
28
  return db;
20
29
  }
@@ -61,10 +70,12 @@ export function parseSessionCookie(cookieHeader: string | null): string | undefi
61
70
  return undefined;
62
71
  }
63
72
 
73
+ const SECURE_COOKIE_FLAG = process.env.NODE_ENV === "production" ? "; Secure" : "";
74
+
64
75
  export function setSessionCookie(token: string): string {
65
- return `${SESSION_COOKIE}=${token}; HttpOnly; SameSite=Lax; Path=/; Max-Age=${SESSION_MAX_AGE}`;
76
+ return `${SESSION_COOKIE}=${token}; HttpOnly; SameSite=Lax; Path=/; Max-Age=${SESSION_MAX_AGE}${SECURE_COOKIE_FLAG}`;
66
77
  }
67
78
 
68
79
  export function clearSessionCookie(): string {
69
- return `${SESSION_COOKIE}=; HttpOnly; SameSite=Lax; Path=/; Max-Age=0`;
80
+ return `${SESSION_COOKIE}=; HttpOnly; SameSite=Lax; Path=/; Max-Age=0${SECURE_COOKIE_FLAG}`;
70
81
  }
@@ -55,12 +55,16 @@ export default function LoginPage({ loaderData }: RouteProps) {
55
55
  <h1 className="text-2xl font-bold text-center">Login</h1>
56
56
  <form method="POST" action="/login" onSubmit={handleSubmit} className="space-y-4">
57
57
  <div className="space-y-2">
58
- <label className="text-sm font-medium">Username</label>
59
- <Input name="username" defaultValue="admin" required />
58
+ <label htmlFor="username" className="text-sm font-medium">
59
+ Username
60
+ </label>
61
+ <Input id="username" name="username" defaultValue="admin" required />
60
62
  </div>
61
63
  <div className="space-y-2">
62
- <label className="text-sm font-medium">Password</label>
63
- <Input name="password" type="password" defaultValue="admin" required />
64
+ <label htmlFor="password" className="text-sm font-medium">
65
+ Password
66
+ </label>
67
+ <Input id="password" name="password" type="password" defaultValue="admin" required />
64
68
  </div>
65
69
  {error && (
66
70
  <p id="login-error" className="text-sm text-destructive">
@@ -72,6 +76,9 @@ export default function LoginPage({ loaderData }: RouteProps) {
72
76
  </Button>
73
77
  </form>
74
78
  <p className="text-xs text-muted-foreground text-center">Demo credentials: admin / admin</p>
79
+ <p className="text-xs text-muted-foreground text-center">
80
+ Demo only — replace with real auth before shipping.
81
+ </p>
75
82
  <p className="text-center">
76
83
  <a
77
84
  href="/"
@@ -26,6 +26,7 @@ export default function PlaceholderPage() {
26
26
  <td className="text-right p-3">100</td>
27
27
  <td className="text-right p-3">
28
28
  <button
29
+ type="button"
29
30
  className="fetch-btn text-primary hover:underline text-xs"
30
31
  data-url="/api/placeholder/posts"
31
32
  >
@@ -42,6 +43,7 @@ export default function PlaceholderPage() {
42
43
  <td className="text-right p-3">500</td>
43
44
  <td className="text-right p-3">
44
45
  <button
46
+ type="button"
45
47
  className="fetch-btn text-primary hover:underline text-xs"
46
48
  data-url="/api/placeholder/comments"
47
49
  >
@@ -56,6 +58,7 @@ export default function PlaceholderPage() {
56
58
  <td className="text-right p-3">200</td>
57
59
  <td className="text-right p-3">
58
60
  <button
61
+ type="button"
59
62
  className="fetch-btn text-primary hover:underline text-xs"
60
63
  data-url="/api/placeholder/todos"
61
64
  >
@@ -70,6 +73,7 @@ export default function PlaceholderPage() {
70
73
  <td className="text-right p-3">10</td>
71
74
  <td className="text-right p-3">
72
75
  <button
76
+ type="button"
73
77
  className="fetch-btn text-primary hover:underline text-xs"
74
78
  data-url="/api/placeholder/users"
75
79
  >
@@ -82,7 +86,11 @@ export default function PlaceholderPage() {
82
86
  All endpoints (sequential)
83
87
  </td>
84
88
  <td className="text-right p-3">
85
- <button id="fetch-all" className="fetch-btn text-primary hover:underline text-xs">
89
+ <button
90
+ id="fetch-all"
91
+ type="button"
92
+ className="fetch-btn text-primary hover:underline text-xs"
93
+ >
86
94
  Fetch All
87
95
  </button>
88
96
  </td>
@@ -59,7 +59,10 @@ export default function HomePage() {
59
59
  placeholder="Enter your email"
60
60
  className="flex-1 rounded-lg border border-input bg-background px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
61
61
  />
62
- <button className="rounded-lg bg-primary px-6 py-2.5 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90">
62
+ <button
63
+ type="button"
64
+ className="rounded-lg bg-primary px-6 py-2.5 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90"
65
+ >
63
66
  Subscribe
64
67
  </button>
65
68
  </div>
@@ -20,7 +20,7 @@ export default function DocPage(_props: RouteProps) {
20
20
  </p>
21
21
  <CodeBlock
22
22
  label="src/lib/db.ts"
23
- code={`import { connectSQLite, runSQLiteMigrations } from "@thexjs/core";
23
+ code={`import { connectSQLite, runSQLiteMigrations } from "@thexjs/core/data";
24
24
 
25
25
  const db = connectSQLite("data/app.db");
26
26
 
@@ -96,7 +96,7 @@ export default function Users({ loaderData }: RouteProps<typeof loader>) {
96
96
  </p>
97
97
  <CodeBlock
98
98
  label="src/lib/db.ts"
99
- code={`import { connectPostgres, runPostgresMigrations } from "@thexjs/core";
99
+ code={`import { connectPostgres, runPostgresMigrations } from "@thexjs/core/data";
100
100
 
101
101
  const db = connectPostgres({
102
102
  connectionString: process.env.DATABASE_URL,
@@ -131,14 +131,14 @@ const html = renderMarkdown(posts[0].body);`}
131
131
  <h2 className="mt-12 text-xl font-bold tracking-tight">Data layer</h2>
132
132
  <CodeBlock
133
133
  label="sqlite"
134
- code={`import { connectSQLite, runSQLiteMigrations } from "@thexjs/core";
134
+ code={`import { connectSQLite, runSQLiteMigrations } from "@thexjs/core/data";
135
135
 
136
136
  const db = connectSQLite({ filename: "./data/dev.db" });
137
137
  await runSQLiteMigrations(db, "./data/migrations");`}
138
138
  />
139
139
  <CodeBlock
140
140
  label="postgres"
141
- code={`import { connectPostgres, runPostgresMigrations } from "@thexjs/core";
141
+ code={`import { connectPostgres, runPostgresMigrations } from "@thexjs/core/data";
142
142
 
143
143
  const sql = connectPostgres({ url: process.env.DATABASE_URL! });
144
144
  await runPostgresMigrations(sql, "./data/migrations");`}
@@ -10,9 +10,10 @@ export default function DocPage(_props: RouteProps) {
10
10
  </p>
11
11
  <h1 className="mt-4 text-3xl font-bold tracking-tight sm:text-4xl">Server functions</h1>
12
12
  <p className="mt-4 text-lg text-muted-foreground">
13
- Call server-side functions directly from the browser without writing REST endpoints. Server
14
- functions live in <span className="text-foreground">src/actions/</span> and are invoked via
15
- fetch.
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.
16
17
  </p>
17
18
 
18
19
  <h2 className="mt-12 text-xl font-bold tracking-tight">Defining server functions</h2>
@@ -37,9 +38,58 @@ export async function sendEmail({ to, subject, body }: {
37
38
  }`}
38
39
  />
39
40
 
40
- <h2 className="mt-12 text-xl font-bold tracking-tight">Calling from the browser</h2>
41
+ <h2 className="mt-12 text-xl font-bold tracking-tight">Calling actions directly</h2>
41
42
  <p className="mt-3 text-muted-foreground">
42
- Server functions are called by sending a POST request to{" "}
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{" "}
43
93
  <span className="text-foreground">/__x/actions/&lt;filename&gt;/&lt;functionName&gt;</span>.
44
94
  The arguments are sent as JSON in the request body.
45
95
  </p>
@@ -82,6 +132,10 @@ export default function GreetForm() {
82
132
  );
83
133
  }`}
84
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>
85
139
 
86
140
  <h2 className="mt-12 text-xl font-bold tracking-tight">Server functions from loaders</h2>
87
141
  <p className="mt-3 text-muted-foreground">
@@ -37,7 +37,7 @@ const allFeatures = [
37
37
  {
38
38
  icon: Server,
39
39
  title: "Server functions",
40
- desc: "Call server-side functions from the browser without writing REST endpoints. Just export async functions from src/actions/ and call them via fetch.",
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
41
  },
42
42
  {
43
43
  icon: Shield,
@@ -1,5 +1,10 @@
1
1
  {
2
2
  "extends": "../../tsconfig.base.json",
3
3
  "compilerOptions": { "noEmit": true, "baseUrl": ".", "paths": { "@/*": ["./src/*"] } },
4
- "include": ["src"]
4
+ "include": [
5
+ "src",
6
+ "../../../core/src/build.ts",
7
+ "../../../core/src/client-nav.ts",
8
+ "../../../core/src/createApp.ts"
9
+ ]
5
10
  }
@@ -0,0 +1,31 @@
1
+ // DEMO ONLY: admin/admin with plaintext comparison via the shared
2
+ // authenticate() helper — replace with real credential storage before shipping.
3
+ import { authenticate, setSessionCookie } from "../../lib/auth";
4
+
5
+ export async function POST(req: Request): Promise<Response> {
6
+ try {
7
+ const body = (await req.json()) as { email?: string; password?: string };
8
+ const { email, password } = body;
9
+
10
+ if (!email || !password) {
11
+ return Response.json({ error: "email and password required" }, { status: 400 });
12
+ }
13
+
14
+ const session = authenticate(email, password);
15
+ if (!session) {
16
+ return Response.json({ error: "invalid credentials" }, { status: 401 });
17
+ }
18
+
19
+ const cookie = setSessionCookie(session.token);
20
+ return new Response(JSON.stringify({ user: { username: session.username } }), {
21
+ status: 200,
22
+ headers: {
23
+ "Content-Type": "application/json",
24
+ "Set-Cookie": cookie,
25
+ },
26
+ });
27
+ } catch (err) {
28
+ console.error("[auth] login error:", err);
29
+ return Response.json({ error: "internal error" }, { status: 500 });
30
+ }
31
+ }
@@ -1,6 +1,11 @@
1
+ import type { Database } from "bun:sqlite";
2
+ // DEMO ONLY: hardcoded admin/admin credentials, plaintext password comparison,
3
+ // no session expiry. This auth is a placeholder for demos — replace with real
4
+ // credential storage (hashed passwords) before shipping anything production.
1
5
  import { randomUUID } from "node:crypto";
2
- import { join } from "node:path";
3
- import { connectSQLite, runSQLiteMigrations } from "@thexjs/core";
6
+ import { mkdirSync } from "node:fs";
7
+ import { dirname, join } from "node:path";
8
+ import { connectSQLite, runSQLiteMigrations } from "@thexjs/core/data";
4
9
 
5
10
  const SESSION_COOKIE = "x_session";
6
11
  const SESSION_MAX_AGE = 60 * 60 * 24 * 7;
@@ -12,9 +17,13 @@ export interface Session {
12
17
  username: string;
13
18
  }
14
19
 
15
- function getDb() {
20
+ let db: Database | null = null;
21
+
22
+ function getDb(): Database {
23
+ if (db) return db;
16
24
  const dbPath = join(import.meta.dir, "..", "..", "data", "dev.db");
17
- const db = connectSQLite({ path: dbPath });
25
+ mkdirSync(dirname(dbPath), { recursive: true });
26
+ db = connectSQLite({ path: dbPath });
18
27
  runSQLiteMigrations(db, join(import.meta.dir, "migrations"));
19
28
  return db;
20
29
  }
@@ -35,6 +44,16 @@ export function createSession(username: string): Session {
35
44
  return { id, token, user_id: userId, username };
36
45
  }
37
46
 
47
+ // DEMO ONLY: the single source of truth for the credential check, shared by
48
+ // the login API route and the login page's server fallback. Replace this with
49
+ // real (hashed) password verification before shipping.
50
+ export function authenticate(email: string, password: string): Session | null {
51
+ if (email === "admin" && password === "admin") {
52
+ return createSession(email);
53
+ }
54
+ return null;
55
+ }
56
+
38
57
  export function getSession(token: string | undefined): Session | null {
39
58
  if (!token) return null;
40
59
  const db = getDb();
@@ -61,10 +80,12 @@ export function parseSessionCookie(cookieHeader: string | null): string | undefi
61
80
  return undefined;
62
81
  }
63
82
 
83
+ const SECURE_COOKIE_FLAG = process.env.NODE_ENV === "production" ? "; Secure" : "";
84
+
64
85
  export function setSessionCookie(token: string): string {
65
- return `${SESSION_COOKIE}=${token}; HttpOnly; SameSite=Lax; Path=/; Max-Age=${SESSION_MAX_AGE}`;
86
+ return `${SESSION_COOKIE}=${token}; HttpOnly; SameSite=Lax; Path=/; Max-Age=${SESSION_MAX_AGE}${SECURE_COOKIE_FLAG}`;
66
87
  }
67
88
 
68
89
  export function clearSessionCookie(): string {
69
- return `${SESSION_COOKIE}=; HttpOnly; SameSite=Lax; Path=/; Max-Age=0`;
90
+ return `${SESSION_COOKIE}=; HttpOnly; SameSite=Lax; Path=/; Max-Age=0${SECURE_COOKIE_FLAG}`;
70
91
  }
@@ -53,7 +53,10 @@ export default function SettingsPage({ loaderData }: RouteProps) {
53
53
  />
54
54
  </div>
55
55
  </div>
56
- <button type="button" className="inline-flex items-center gap-2 rounded-xl bg-primary px-5 py-2.5 text-sm font-semibold text-primary-foreground shadow-lg shadow-primary/20 transition-all hover:bg-primary/90">
56
+ <button
57
+ type="button"
58
+ className="inline-flex items-center gap-2 rounded-xl bg-primary px-5 py-2.5 text-sm font-semibold text-primary-foreground shadow-lg shadow-primary/20 transition-all hover:bg-primary/90"
59
+ >
57
60
  <Save className="h-4 w-4" />
58
61
  Save Changes
59
62
  </button>
@@ -95,7 +98,10 @@ export default function SettingsPage({ loaderData }: RouteProps) {
95
98
  <p className="text-sm text-muted-foreground mb-4">
96
99
  Permanently delete your account and all associated data.
97
100
  </p>
98
- <button type="button" className="rounded-xl border border-destructive/50 bg-destructive/10 px-5 py-2.5 text-sm font-semibold text-destructive transition-all hover:bg-destructive/20">
101
+ <button
102
+ type="button"
103
+ className="rounded-xl border border-destructive/50 bg-destructive/10 px-5 py-2.5 text-sm font-semibold text-destructive transition-all hover:bg-destructive/20"
104
+ >
99
105
  Delete Account
100
106
  </button>
101
107
  </div>
@@ -1,7 +1,60 @@
1
+ import type { LoaderArgs, RouteProps } from "@thexjs/core";
1
2
  import { LogIn } from "lucide-react";
3
+ import { useState } from "react";
4
+ import { Button } from "../components/ui/button";
5
+ import { Input } from "../components/ui/input";
6
+ import { authenticate, setSessionCookie } from "../lib/auth";
2
7
  import { cn } from "../lib/utils";
3
8
 
4
- export default function LoginPage() {
9
+ export async function loader({ request }: LoaderArgs) {
10
+ if (request.method === "POST") {
11
+ const formData = await request.formData();
12
+ const username = formData.get("email") as string | null;
13
+ const password = formData.get("password") as string | null;
14
+ const session = username && password ? authenticate(username, password) : null;
15
+ if (session) {
16
+ return new Response(null, {
17
+ status: 302,
18
+ headers: { Location: "/dashboard", "Set-Cookie": setSessionCookie(session.token) },
19
+ });
20
+ }
21
+ return { error: "Invalid credentials" };
22
+ }
23
+ return {};
24
+ }
25
+
26
+ export default function LoginPage({ loaderData }: RouteProps) {
27
+ const [error, setError] = useState((loaderData?.error as string) ?? "");
28
+ const [loading, setLoading] = useState(false);
29
+
30
+ async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
31
+ e.preventDefault();
32
+ setError("");
33
+ setLoading(true);
34
+ const form = e.currentTarget;
35
+ const data = {
36
+ email: (form.elements.namedItem("email") as HTMLInputElement).value,
37
+ password: (form.elements.namedItem("password") as HTMLInputElement).value,
38
+ };
39
+ try {
40
+ const res = await fetch("/api/auth/login", {
41
+ method: "POST",
42
+ headers: { "Content-Type": "application/json" },
43
+ body: JSON.stringify(data),
44
+ });
45
+ if (res.ok) {
46
+ window.location.href = "/dashboard";
47
+ } else {
48
+ const err = (await res.json()) as { error?: string };
49
+ setError(err.error || "Login failed");
50
+ }
51
+ } catch {
52
+ setError("Network error");
53
+ } finally {
54
+ setLoading(false);
55
+ }
56
+ }
57
+
5
58
  return (
6
59
  <div className="flex min-h-[calc(100vh-4rem)] items-center justify-center px-4">
7
60
  <div className="w-full max-w-sm">
@@ -15,7 +68,7 @@ export default function LoginPage() {
15
68
  </h1>
16
69
  <p className="mt-2 text-sm text-muted-foreground">Sign in to your account</p>
17
70
  </div>
18
- <form className="space-y-5">
71
+ <form method="POST" action="/login" onSubmit={handleSubmit} className="space-y-5">
19
72
  <div>
20
73
  <label
21
74
  htmlFor="email"
@@ -23,11 +76,16 @@ export default function LoginPage() {
23
76
  >
24
77
  Email
25
78
  </label>
26
- <input
79
+ <Input
27
80
  id="email"
81
+ name="email"
28
82
  type="email"
83
+ defaultValue="admin"
29
84
  placeholder="you@example.com"
30
- className="w-full rounded-xl border border-input bg-background px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:border-ring focus:outline-none focus:ring-2 focus:ring-ring/20"
85
+ className={cn(
86
+ "h-10 rounded-xl border-input bg-background px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground",
87
+ )}
88
+ required
31
89
  />
32
90
  </div>
33
91
  <div>
@@ -37,20 +95,35 @@ export default function LoginPage() {
37
95
  >
38
96
  Password
39
97
  </label>
40
- <input
98
+ <Input
41
99
  id="password"
100
+ name="password"
42
101
  type="password"
102
+ defaultValue="admin"
43
103
  placeholder="••••••••"
44
- className="w-full rounded-xl border border-input bg-background px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:border-ring focus:outline-none focus:ring-2 focus:ring-ring/20"
104
+ className="h-10 rounded-xl border-input bg-background px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground"
105
+ required
45
106
  />
46
107
  </div>
47
- <button
108
+ {error && (
109
+ <p id="login-error" className="text-sm text-destructive">
110
+ {error}
111
+ </p>
112
+ )}
113
+ <Button
48
114
  type="submit"
49
- className="w-full rounded-xl bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-lg shadow-primary/20 transition-all hover:bg-primary/90 hover:shadow-xl hover:shadow-primary/25"
115
+ disabled={loading}
116
+ className="h-10 w-full rounded-xl bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-lg shadow-primary/20 transition-all hover:bg-primary/90 hover:shadow-xl hover:shadow-primary/25"
50
117
  >
51
- Sign in
52
- </button>
118
+ {loading ? "Signing in..." : "Sign in"}
119
+ </Button>
53
120
  </form>
121
+ <p className="mt-4 text-center text-xs text-muted-foreground">
122
+ Demo credentials: <code className="text-foreground">admin / admin</code>
123
+ </p>
124
+ <p className="mt-1 text-center text-[11px] text-muted-foreground">
125
+ Demo only — replace with real auth before shipping.
126
+ </p>
54
127
  <p className="mt-6 text-center text-sm text-muted-foreground">
55
128
  Don&apos;t have an account?{" "}
56
129
  <a
@@ -1,95 +0,0 @@
1
- import { Mail, MapPin, Send } from "lucide-react";
2
-
3
- export default function ContactPage() {
4
- return (
5
- <div className="mx-auto max-w-4xl px-6 py-20">
6
- <div className="mx-auto max-w-2xl text-center">
7
- <p className="text-xs font-semibold uppercase tracking-[0.2em] text-primary">Contact</p>
8
- <h1 className="mt-4 text-4xl font-bold tracking-tight sm:text-5xl">Get in touch</h1>
9
- <p className="mt-4 text-lg text-muted-foreground">
10
- Have a question or want to learn more? We'd love to hear from you.
11
- </p>
12
- </div>
13
-
14
- <div className="mt-16 grid gap-12 sm:grid-cols-5">
15
- <div className="space-y-8 sm:col-span-2">
16
- <div>
17
- <div className="flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary">
18
- <Mail className="h-5 w-5" />
19
- </div>
20
- <h3 className="mt-4 text-sm font-semibold">Email</h3>
21
- <p className="mt-1 text-sm text-muted-foreground">hello@x-framework.dev</p>
22
- </div>
23
- <div>
24
- <div className="flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary">
25
- <MapPin className="h-5 w-5" />
26
- </div>
27
- <h3 className="mt-4 text-sm font-semibold">Location</h3>
28
- <p className="mt-1 text-sm text-muted-foreground">San Francisco, CA</p>
29
- </div>
30
- </div>
31
-
32
- <form className="space-y-5 sm:col-span-3" method="POST" action="/contact">
33
- <div className="grid gap-5 sm:grid-cols-2">
34
- <div>
35
- <label htmlFor="name" className="block text-sm font-medium mb-2">
36
- Name
37
- </label>
38
- <input
39
- id="name"
40
- name="name"
41
- required
42
- className="w-full rounded-xl border border-input bg-card px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
43
- placeholder="Your name"
44
- />
45
- </div>
46
- <div>
47
- <label htmlFor="email" className="block text-sm font-medium mb-2">
48
- Email
49
- </label>
50
- <input
51
- id="email"
52
- name="email"
53
- type="email"
54
- required
55
- className="w-full rounded-xl border border-input bg-card px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
56
- placeholder="you@example.com"
57
- />
58
- </div>
59
- </div>
60
- <div>
61
- <label htmlFor="subject" className="block text-sm font-medium mb-2">
62
- Subject
63
- </label>
64
- <input
65
- id="subject"
66
- name="subject"
67
- required
68
- className="w-full rounded-xl border border-input bg-card px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
69
- placeholder="How can we help?"
70
- />
71
- </div>
72
- <div>
73
- <label htmlFor="message" className="block text-sm font-medium mb-2">
74
- Message
75
- </label>
76
- <textarea
77
- id="message"
78
- name="message"
79
- rows={5}
80
- required
81
- className="w-full resize-none rounded-xl border border-input bg-card px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
82
- placeholder="Tell us more..."
83
- />
84
- </div>
85
- <button
86
- type="submit"
87
- className="inline-flex h-11 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"
88
- >
89
- Send message <Send className="h-4 w-4" />
90
- </button>
91
- </form>
92
- </div>
93
- </div>
94
- );
95
- }