create-neutron 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +201 -0
  6. package/dist/index.js.map +1 -0
  7. package/package.json +45 -0
  8. package/templates/app/_gitignore +3 -0
  9. package/templates/app/index.html +12 -0
  10. package/templates/app/neutron.config.ts +5 -0
  11. package/templates/app/package.json +24 -0
  12. package/templates/app/src/main.tsx +5 -0
  13. package/templates/app/src/routes/_layout.tsx +18 -0
  14. package/templates/app/src/routes/api/session/refresh.tsx +28 -0
  15. package/templates/app/src/routes/app/dashboard.tsx +39 -0
  16. package/templates/app/src/routes/app/settings.tsx +68 -0
  17. package/templates/app/src/routes/index.tsx +26 -0
  18. package/templates/app/src/routes/login.tsx +14 -0
  19. package/templates/app/src/routes/protected.tsx +53 -0
  20. package/templates/app/src/routes/users/[id].tsx +26 -0
  21. package/templates/app/tsconfig.json +14 -0
  22. package/templates/app/vite.config.ts +7 -0
  23. package/templates/basic/_gitignore +3 -0
  24. package/templates/basic/index.html +12 -0
  25. package/templates/basic/neutron.config.ts +5 -0
  26. package/templates/basic/package.json +24 -0
  27. package/templates/basic/src/main.tsx +5 -0
  28. package/templates/basic/src/routes/_layout.tsx +16 -0
  29. package/templates/basic/src/routes/index.tsx +19 -0
  30. package/templates/basic/src/routes/users/[id].tsx +26 -0
  31. package/templates/basic/tsconfig.json +14 -0
  32. package/templates/basic/vite.config.ts +7 -0
  33. package/templates/docs/_gitignore +3 -0
  34. package/templates/docs/index.html +12 -0
  35. package/templates/docs/neutron.config.ts +8 -0
  36. package/templates/docs/package.json +22 -0
  37. package/templates/docs/public/favicon.svg +1 -0
  38. package/templates/docs/src/components/Breadcrumbs.tsx +47 -0
  39. package/templates/docs/src/components/Callout.tsx +40 -0
  40. package/templates/docs/src/components/Card.tsx +31 -0
  41. package/templates/docs/src/components/CopyButton.tsx +35 -0
  42. package/templates/docs/src/components/Footer.tsx +72 -0
  43. package/templates/docs/src/components/Search.tsx +139 -0
  44. package/templates/docs/src/components/Sidebar.tsx +59 -0
  45. package/templates/docs/src/components/SidebarToggle.tsx +47 -0
  46. package/templates/docs/src/components/Steps.tsx +9 -0
  47. package/templates/docs/src/components/Tabs.tsx +35 -0
  48. package/templates/docs/src/components/ThemeToggle.tsx +45 -0
  49. package/templates/docs/src/components/Toc.tsx +36 -0
  50. package/templates/docs/src/components/TocTracker.tsx +35 -0
  51. package/templates/docs/src/content/config.ts +13 -0
  52. package/templates/docs/src/content/docs/getting-started/installation.mdx +18 -0
  53. package/templates/docs/src/content/docs/getting-started/quick-start.mdx +19 -0
  54. package/templates/docs/src/content/docs/index.mdx +13 -0
  55. package/templates/docs/src/lib/pagination.ts +39 -0
  56. package/templates/docs/src/lib/sidebar.ts +100 -0
  57. package/templates/docs/src/main.tsx +8 -0
  58. package/templates/docs/src/routes/_layout.tsx +27 -0
  59. package/templates/docs/src/routes/docs/[...slug].tsx +85 -0
  60. package/templates/docs/src/routes/docs/_layout.tsx +47 -0
  61. package/templates/docs/src/styles/code.css +188 -0
  62. package/templates/docs/src/styles/components.css +264 -0
  63. package/templates/docs/src/styles/docs.css +416 -0
  64. package/templates/docs/src/styles/prose.css +224 -0
  65. package/templates/docs/src/styles/search.css +225 -0
  66. package/templates/docs/tsconfig.json +19 -0
  67. package/templates/docs/vite.config.ts +6 -0
  68. package/templates/full/_gitignore +3 -0
  69. package/templates/full/index.html +12 -0
  70. package/templates/full/neutron.config.ts +5 -0
  71. package/templates/full/package.json +24 -0
  72. package/templates/full/src/components/Counter.tsx +13 -0
  73. package/templates/full/src/main.tsx +5 -0
  74. package/templates/full/src/routes/(marketing)/pricing.tsx +15 -0
  75. package/templates/full/src/routes/_layout.tsx +17 -0
  76. package/templates/full/src/routes/app/dashboard.tsx +28 -0
  77. package/templates/full/src/routes/app/settings.tsx +42 -0
  78. package/templates/full/src/routes/index.tsx +31 -0
  79. package/templates/full/src/routes/users/[id].tsx +26 -0
  80. package/templates/full/tsconfig.json +14 -0
  81. package/templates/full/vite.config.ts +7 -0
  82. package/templates/marketing/_gitignore +3 -0
  83. package/templates/marketing/index.html +12 -0
  84. package/templates/marketing/neutron.config.ts +5 -0
  85. package/templates/marketing/package.json +24 -0
  86. package/templates/marketing/src/components/Counter.tsx +14 -0
  87. package/templates/marketing/src/main.tsx +5 -0
  88. package/templates/marketing/src/routes/_layout.tsx +16 -0
  89. package/templates/marketing/src/routes/about.tsx +10 -0
  90. package/templates/marketing/src/routes/blog/[slug].tsx +34 -0
  91. package/templates/marketing/src/routes/blog/index.tsx +27 -0
  92. package/templates/marketing/src/routes/index.tsx +26 -0
  93. package/templates/marketing/src/routes/users/index.tsx +10 -0
  94. package/templates/marketing/tsconfig.json +14 -0
  95. package/templates/marketing/vite.config.ts +7 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tyler
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # create-neutron
2
+
3
+ Scaffold a new Neutron project.
4
+
5
+ Project scaffolding with templates for static sites, marketing pages, SaaS apps, and documentation.
6
+
7
+ ## Installation
8
+
9
+ ## Usage
10
+
11
+ ```bash
12
+ npm create @neutron-build
13
+ # or
14
+ pnpm create @neutron-build
15
+ # or
16
+ bun create @neutron-build
17
+ ```
18
+
19
+ ## Documentation
20
+
21
+ [neutron.build](https://neutron.build)
22
+
23
+ ## License
24
+
25
+ MIT
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,201 @@
1
+ #!/usr/bin/env node
2
+ import * as fs from "node:fs";
3
+ import * as fsp from "node:fs/promises";
4
+ import * as path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ const TEMPLATE_NAMES = ["basic", "marketing", "app", "full", "docs"];
7
+ async function main() {
8
+ const options = parseArgs(process.argv.slice(2));
9
+ if (!options) {
10
+ printUsage();
11
+ process.exit(1);
12
+ }
13
+ if (options.targetDir === "--help" || options.targetDir === "-h") {
14
+ printUsage();
15
+ return;
16
+ }
17
+ const absoluteTargetDir = path.resolve(process.cwd(), options.targetDir);
18
+ const packageName = toPackageName(path.basename(absoluteTargetDir));
19
+ const dependencyVersions = resolveDependencyVersions(absoluteTargetDir);
20
+ await ensureTargetDirectory(absoluteTargetDir);
21
+ await copyTemplate(options.template, absoluteTargetDir, {
22
+ PROJECT_NAME: path.basename(absoluteTargetDir),
23
+ PACKAGE_NAME: packageName,
24
+ RUNTIME: options.runtime,
25
+ NEUTRON_VERSION: dependencyVersions.neutron,
26
+ NEUTRON_CLI_VERSION: dependencyVersions.neutronCli,
27
+ });
28
+ printSuccess(path.basename(absoluteTargetDir), options.template, options.runtime);
29
+ }
30
+ function parseArgs(argv) {
31
+ const positional = [];
32
+ let template = "basic";
33
+ let runtime = "preact";
34
+ for (let i = 0; i < argv.length; i++) {
35
+ const arg = argv[i];
36
+ if (!arg) {
37
+ continue;
38
+ }
39
+ if (arg === "--template" && argv[i + 1]) {
40
+ const candidate = argv[++i];
41
+ if (isTemplateName(candidate)) {
42
+ template = candidate;
43
+ }
44
+ else {
45
+ console.error(`Unsupported template: ${candidate}`);
46
+ return null;
47
+ }
48
+ continue;
49
+ }
50
+ if (arg.startsWith("--template=")) {
51
+ const candidate = arg.split("=")[1];
52
+ if (isTemplateName(candidate)) {
53
+ template = candidate;
54
+ }
55
+ else {
56
+ console.error(`Unsupported template: ${candidate}`);
57
+ return null;
58
+ }
59
+ continue;
60
+ }
61
+ if (arg === "--runtime" && argv[i + 1]) {
62
+ const candidate = argv[++i];
63
+ if (candidate === "preact" || candidate === "react-compat") {
64
+ runtime = candidate;
65
+ }
66
+ else {
67
+ console.error(`Unsupported runtime: ${candidate}`);
68
+ return null;
69
+ }
70
+ continue;
71
+ }
72
+ if (arg.startsWith("--runtime=")) {
73
+ const candidate = arg.split("=")[1];
74
+ if (candidate === "preact" || candidate === "react-compat") {
75
+ runtime = candidate;
76
+ }
77
+ else {
78
+ console.error(`Unsupported runtime: ${candidate}`);
79
+ return null;
80
+ }
81
+ continue;
82
+ }
83
+ positional.push(arg);
84
+ }
85
+ const targetDir = positional[0] || "neutron-app";
86
+ return { targetDir, template, runtime };
87
+ }
88
+ function printUsage() {
89
+ console.log(`Usage:
90
+ create-neutron [project-name] [options]
91
+
92
+ Options:
93
+ --template <name> Template to use (default: basic)
94
+ ${TEMPLATE_NAMES.join(" | ")}
95
+ --runtime <mode> Runtime mode: preact | react-compat (default: preact)
96
+ -h, --help Show this help message`);
97
+ }
98
+ function printSuccess(projectName, template, runtime) {
99
+ console.log(`\nCreated ${projectName} (template: ${template}, runtime: ${runtime})\n`);
100
+ console.log("Next steps:");
101
+ console.log(` cd ${projectName}`);
102
+ console.log(" pnpm install");
103
+ console.log(" pnpm dev\n");
104
+ }
105
+ async function ensureTargetDirectory(targetDir) {
106
+ if (!fs.existsSync(targetDir)) {
107
+ await fsp.mkdir(targetDir, { recursive: true });
108
+ return;
109
+ }
110
+ const files = await fsp.readdir(targetDir);
111
+ if (files.length > 0) {
112
+ throw new Error(`Target directory is not empty: ${targetDir}`);
113
+ }
114
+ }
115
+ async function copyTemplate(template, targetDir, tokens) {
116
+ const templateRoot = getTemplateRoot();
117
+ const sourceDir = path.join(templateRoot, template);
118
+ if (!fs.existsSync(sourceDir)) {
119
+ throw new Error(`Template not found: ${template}`);
120
+ }
121
+ await copyDirectory(sourceDir, targetDir, tokens);
122
+ }
123
+ async function copyDirectory(sourceDir, targetDir, tokens) {
124
+ await fsp.mkdir(targetDir, { recursive: true });
125
+ const entries = await fsp.readdir(sourceDir, { withFileTypes: true });
126
+ for (const entry of entries) {
127
+ const sourcePath = path.join(sourceDir, entry.name);
128
+ const outputName = resolveOutputName(entry.name);
129
+ const outputPath = path.join(targetDir, outputName);
130
+ if (entry.isDirectory()) {
131
+ await copyDirectory(sourcePath, outputPath, tokens);
132
+ continue;
133
+ }
134
+ const source = await fsp.readFile(sourcePath, "utf-8");
135
+ const rendered = applyTokens(source, tokens);
136
+ await fsp.writeFile(outputPath, rendered, "utf-8");
137
+ }
138
+ }
139
+ function resolveOutputName(inputName) {
140
+ if (inputName === "_gitignore") {
141
+ return ".gitignore";
142
+ }
143
+ return inputName;
144
+ }
145
+ function applyTokens(source, tokens) {
146
+ let output = source;
147
+ for (const [key, value] of Object.entries(tokens)) {
148
+ output = output.replaceAll(`__${key}__`, value);
149
+ }
150
+ return output;
151
+ }
152
+ function toPackageName(input) {
153
+ const normalized = input
154
+ .toLowerCase()
155
+ .replace(/[^a-z0-9-]+/g, "-")
156
+ .replace(/^-+|-+$/g, "");
157
+ return normalized || "neutron-app";
158
+ }
159
+ function isTemplateName(value) {
160
+ return TEMPLATE_NAMES.includes(value);
161
+ }
162
+ function resolveDependencyVersions(targetDir) {
163
+ const workspaceRoot = findWorkspaceRoot(path.dirname(targetDir));
164
+ if (!workspaceRoot) {
165
+ return {
166
+ neutron: "latest",
167
+ neutronCli: "latest",
168
+ };
169
+ }
170
+ return {
171
+ neutron: "workspace:*",
172
+ neutronCli: "workspace:*",
173
+ };
174
+ }
175
+ function findWorkspaceRoot(startDir) {
176
+ let current = path.resolve(startDir);
177
+ while (true) {
178
+ const hasWorkspaceConfig = fs.existsSync(path.join(current, "pnpm-workspace.yaml"));
179
+ const hasNeutronPackage = fs.existsSync(path.join(current, "packages", "neutron"));
180
+ const hasNeutronCliPackage = fs.existsSync(path.join(current, "packages", "neutron-cli"));
181
+ if (hasWorkspaceConfig && hasNeutronPackage && hasNeutronCliPackage) {
182
+ return current;
183
+ }
184
+ const parent = path.dirname(current);
185
+ if (parent === current) {
186
+ return null;
187
+ }
188
+ current = parent;
189
+ }
190
+ }
191
+ function getTemplateRoot() {
192
+ const currentFile = fileURLToPath(import.meta.url);
193
+ const currentDir = path.dirname(currentFile);
194
+ return path.resolve(currentDir, "..", "templates");
195
+ }
196
+ main().catch((error) => {
197
+ console.error("\nFailed to create Neutron app.");
198
+ console.error(error);
199
+ process.exit(1);
200
+ });
201
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAKzC,MAAM,cAAc,GAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAA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AG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AACrD,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACjD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "create-neutron",
3
+ "version": "0.1.0",
4
+ "description": "Scaffold a new Neutron project. Run with: npm create neutron@latest",
5
+ "author": "Tyler",
6
+ "license": "MIT",
7
+ "homepage": "https://neutron.build",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/neutron-build/neutron",
11
+ "directory": "typescript/packages/create-neutron"
12
+ },
13
+ "keywords": [
14
+ "neutron",
15
+ "create",
16
+ "scaffold",
17
+ "starter",
18
+ "template"
19
+ ],
20
+ "type": "module",
21
+ "bin": {
22
+ "create-neutron": "./dist/index.js"
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "!dist/**/*.test.*",
27
+ "templates"
28
+ ],
29
+ "devDependencies": {
30
+ "@types/node": "^22.10.7",
31
+ "typescript": "^5.7.2"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "engines": {
37
+ "node": ">=20"
38
+ },
39
+ "scripts": {
40
+ "build": "tsc",
41
+ "dev": "tsc --watch",
42
+ "lint": "tsc --noEmit --pretty false",
43
+ "test": "pnpm run build && node --test --experimental-test-isolation=none dist/index.test.js"
44
+ }
45
+ }
@@ -0,0 +1,3 @@
1
+ node_modules
2
+ dist
3
+ .neutron
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>__PROJECT_NAME__</title>
7
+ </head>
8
+ <body>
9
+ <div id="app"></div>
10
+ <script type="module" src="/src/main.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,5 @@
1
+ import { defineConfig } from "@neutron-build/core";
2
+
3
+ export default defineConfig({
4
+ runtime: "__RUNTIME__",
5
+ });
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "__PACKAGE_NAME__",
3
+ "private": true,
4
+ "version": "0.0.1",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "neutron dev",
8
+ "build": "neutron build",
9
+ "build:vercel": "neutron build --preset vercel",
10
+ "start": "neutron start",
11
+ "preview": "neutron preview",
12
+ "release:check": "neutron release-check --preset vercel"
13
+ },
14
+ "dependencies": {
15
+ "@neutron-build/core": "__NEUTRON_VERSION__",
16
+ "@neutron-build/cli": "__NEUTRON_CLI_VERSION__",
17
+ "preact": "^10.25.4"
18
+ },
19
+ "devDependencies": {
20
+ "@preact/preset-vite": "^2.9.4",
21
+ "typescript": "^5.7.2",
22
+ "vite": "^6.0.7"
23
+ }
24
+ }
@@ -0,0 +1,5 @@
1
+ import { init, registerRoutes } from "@neutron-build/core/client";
2
+ import { routes } from "virtual:neutron/routes";
3
+
4
+ registerRoutes(routes);
5
+ void init();
@@ -0,0 +1,18 @@
1
+ export default function Layout(props: { children?: unknown }) {
2
+ return (
3
+ <div style="max-width: 900px; margin: 0 auto; padding: 2rem; font-family: system-ui, sans-serif;">
4
+ <header style="margin-bottom: 1.5rem;">
5
+ <h1 style="margin: 0;">__PROJECT_NAME__</h1>
6
+ <p style="color: #666;">Neutron SaaS template</p>
7
+ </header>
8
+ <nav style="display: flex; gap: 0.75rem; margin-bottom: 1.5rem;">
9
+ <a href="/">Home</a>
10
+ <a href="/app/dashboard">Dashboard</a>
11
+ <a href="/app/settings">Settings</a>
12
+ <a href="/login">Login</a>
13
+ <a href="/protected?token=demo">Protected</a>
14
+ </nav>
15
+ <main>{props.children}</main>
16
+ </div>
17
+ );
18
+ }
@@ -0,0 +1,28 @@
1
+ import type { ActionArgs } from "@neutron-build/core";
2
+
3
+ export const config = { mode: "app" };
4
+
5
+ export async function action({ request }: ActionArgs) {
6
+ const auth = request.headers.get("authorization") || "";
7
+ const token = auth.replace(/^Bearer\s+/i, "");
8
+
9
+ if (token !== "demo") {
10
+ return Response.json(
11
+ { refreshed: false, error: "unauthorized" },
12
+ { status: 401, headers: { "Cache-Control": "no-store" } }
13
+ );
14
+ }
15
+
16
+ return Response.json(
17
+ {
18
+ refreshed: true,
19
+ refreshedAt: new Date().toISOString(),
20
+ ttlSec: 3600,
21
+ },
22
+ { headers: { "Cache-Control": "no-store" } }
23
+ );
24
+ }
25
+
26
+ export default function SessionRefreshRoute() {
27
+ return null;
28
+ }
@@ -0,0 +1,39 @@
1
+ import type { LoaderArgs } from "@neutron-build/core";
2
+
3
+ export const config = { mode: "app", cache: { maxAge: 30, loaderMaxAge: 10 } };
4
+
5
+ export async function loader({ request }: LoaderArgs) {
6
+ const url = new URL(request.url);
7
+ const workspace = url.searchParams.get("workspace") || "main";
8
+
9
+ return {
10
+ workspace,
11
+ stats: {
12
+ users: 12,
13
+ projects: 4,
14
+ uptime: "99.99%",
15
+ },
16
+ loadedAt: new Date().toISOString(),
17
+ };
18
+ }
19
+
20
+ export default function Dashboard(props: {
21
+ data?: {
22
+ workspace: string;
23
+ stats: { users: number; projects: number; uptime: string };
24
+ loadedAt: string;
25
+ };
26
+ }) {
27
+ return (
28
+ <section>
29
+ <h2>Dashboard</h2>
30
+ <p>Workspace: <strong>{props.data?.workspace}</strong></p>
31
+ <ul>
32
+ <li>Users: {props.data?.stats.users}</li>
33
+ <li>Projects: {props.data?.stats.projects}</li>
34
+ <li>Uptime: {props.data?.stats.uptime}</li>
35
+ </ul>
36
+ <p>Loaded at {props.data?.loadedAt}</p>
37
+ </section>
38
+ );
39
+ }
@@ -0,0 +1,68 @@
1
+ import { Form } from "@neutron-build/core/client";
2
+ import type { ActionArgs } from "@neutron-build/core";
3
+
4
+ export const config = { mode: "app" };
5
+
6
+ export async function loader() {
7
+ return {
8
+ currentName: "Acme Inc",
9
+ currentTheme: "system",
10
+ };
11
+ }
12
+
13
+ export async function action({ request }: ActionArgs) {
14
+ const formData = await request.formData();
15
+ const name = String(formData.get("name") || "").trim();
16
+ const theme = String(formData.get("theme") || "system").trim();
17
+
18
+ return Response.json({
19
+ ok: true,
20
+ saved: {
21
+ name: name || "Unnamed Workspace",
22
+ theme,
23
+ },
24
+ updatedAt: new Date().toISOString(),
25
+ });
26
+ }
27
+
28
+ export default function Settings(props: {
29
+ data?: { currentName: string; currentTheme: string };
30
+ actionData?: {
31
+ ok: boolean;
32
+ saved: { name: string; theme: string };
33
+ updatedAt: string;
34
+ };
35
+ }) {
36
+ return (
37
+ <section>
38
+ <h2>Settings</h2>
39
+ <Form method="post" style={{ display: "grid", gap: "0.75rem", maxWidth: "420px" }}>
40
+ <label>
41
+ Workspace Name
42
+ <input
43
+ type="text"
44
+ name="name"
45
+ defaultValue={props.data?.currentName}
46
+ style={{ width: "100%" }}
47
+ />
48
+ </label>
49
+ <label>
50
+ Theme
51
+ <select name="theme" defaultValue={props.data?.currentTheme}>
52
+ <option value="system">System</option>
53
+ <option value="light">Light</option>
54
+ <option value="dark">Dark</option>
55
+ </select>
56
+ </label>
57
+ <button type="submit">Save</button>
58
+ </Form>
59
+
60
+ {props.actionData?.ok ? (
61
+ <p style={{ marginTop: "1rem" }}>
62
+ Saved <strong>{props.actionData.saved.name}</strong> ({props.actionData.saved.theme}) at{" "}
63
+ {props.actionData.updatedAt}
64
+ </p>
65
+ ) : null}
66
+ </section>
67
+ );
68
+ }
@@ -0,0 +1,26 @@
1
+ export const config = { mode: "static" };
2
+
3
+ export async function loader() {
4
+ return {
5
+ title: "__PROJECT_NAME__",
6
+ generatedAt: new Date().toISOString().slice(0, 19).replace("T", " "),
7
+ };
8
+ }
9
+
10
+ export default function Home(props: { data?: { title: string; generatedAt: string } }) {
11
+ return (
12
+ <section>
13
+ <h2>{props.data?.title}</h2>
14
+ <p>
15
+ SaaS-oriented starter with app routes, loaders, actions, and auth-ready patterns.
16
+ </p>
17
+ <ul>
18
+ <li><a href="/app/dashboard">Dashboard</a></li>
19
+ <li><a href="/app/settings">Settings (action + Form)</a></li>
20
+ <li><a href="/login">Login</a></li>
21
+ <li><a href="/protected?token=demo">Protected route demo</a></li>
22
+ </ul>
23
+ <p>Generated at <strong>{props.data?.generatedAt}</strong>.</p>
24
+ </section>
25
+ );
26
+ }
@@ -0,0 +1,14 @@
1
+ export const config = { mode: "app" };
2
+
3
+ export default function Login() {
4
+ return (
5
+ <section>
6
+ <h2>Login</h2>
7
+ <p>This template keeps auth logic explicit in routes/middleware.</p>
8
+ <p>Demo token for local checks: <code>demo</code></p>
9
+ <p>
10
+ Try <a href="/protected?token=demo">/protected?token=demo</a>.
11
+ </p>
12
+ </section>
13
+ );
14
+ }
@@ -0,0 +1,53 @@
1
+ import type { LoaderArgs } from "@neutron-build/core";
2
+
3
+ export const config = { mode: "app", cache: { maxAge: 10 } };
4
+
5
+ export async function loader({ request }: LoaderArgs) {
6
+ const url = new URL(request.url);
7
+ const tokenFromHeader = request.headers.get("authorization")?.replace(/^Bearer\s+/i, "");
8
+ const tokenFromQuery = url.searchParams.get("token");
9
+ const token = tokenFromHeader || tokenFromQuery;
10
+
11
+ if (token !== "demo") {
12
+ return {
13
+ authorized: false,
14
+ reason: "Missing or invalid token. Provide ?token=demo for local testing.",
15
+ };
16
+ }
17
+
18
+ return {
19
+ authorized: true,
20
+ account: {
21
+ id: "acct_demo",
22
+ plan: "pro",
23
+ },
24
+ loadedAt: new Date().toISOString(),
25
+ };
26
+ }
27
+
28
+ export default function Protected(props: {
29
+ data?: {
30
+ authorized: boolean;
31
+ reason?: string;
32
+ account?: { id: string; plan: string };
33
+ loadedAt?: string;
34
+ };
35
+ }) {
36
+ if (!props.data?.authorized) {
37
+ return (
38
+ <section>
39
+ <h2>Protected</h2>
40
+ <p>{props.data?.reason}</p>
41
+ </section>
42
+ );
43
+ }
44
+
45
+ return (
46
+ <section>
47
+ <h2>Protected</h2>
48
+ <p>Account: {props.data?.account?.id}</p>
49
+ <p>Plan: {props.data?.account?.plan}</p>
50
+ <p>Loaded at {props.data?.loadedAt}</p>
51
+ </section>
52
+ );
53
+ }
@@ -0,0 +1,26 @@
1
+ import type { LoaderArgs } from "@neutron-build/core";
2
+
3
+ export const config = { mode: "app", cache: { maxAge: 30 } };
4
+
5
+ export async function loader({ params }: LoaderArgs) {
6
+ const id = params.id || "1";
7
+ return {
8
+ user: {
9
+ id,
10
+ name: `User ${id}`,
11
+ email: `user${id}@example.com`,
12
+ },
13
+ };
14
+ }
15
+
16
+ export default function UserRoute(props: {
17
+ data?: { user: { id: string; name: string; email: string } };
18
+ }) {
19
+ return (
20
+ <section>
21
+ <h2>{props.data?.user.name}</h2>
22
+ <p>ID: {props.data?.user.id}</p>
23
+ <p>Email: {props.data?.user.email}</p>
24
+ </section>
25
+ );
26
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "lib": ["ES2022", "DOM"],
7
+ "jsx": "react-jsx",
8
+ "jsxImportSource": "preact",
9
+ "strict": true,
10
+ "skipLibCheck": true,
11
+ "types": ["vite/client"]
12
+ },
13
+ "include": ["src"]
14
+ }