create-nowaki 0.15.0 → 0.17.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/package.json
CHANGED
|
@@ -15,6 +15,12 @@ npm run prerender # nowaki prerender — static export
|
|
|
15
15
|
npx nowaki upgrade # update nowaki (CLI) + @nowaki-dev/runtime to latest
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
+
While `npm run dev` runs, the dev server also serves a read-only MCP endpoint
|
|
19
|
+
(loopback only) at `http://127.0.0.1:3000/__nowaki/mcp`, with the tools `routes`,
|
|
20
|
+
`module_graph`, `recent_errors`, and `dev_config`. Add it to Claude Code with
|
|
21
|
+
`claude mcp add --transport http nowaki http://127.0.0.1:3000/__nowaki/mcp`.
|
|
22
|
+
After an edit or a failing request, check `recent_errors` first.
|
|
23
|
+
|
|
18
24
|
## Project layout
|
|
19
25
|
|
|
20
26
|
```
|
|
@@ -105,6 +111,14 @@ nowaki.config.mjs plugins (optional)
|
|
|
105
111
|
8. **Jetstream islands** (server-reactive, zero client JS) — give an island
|
|
106
112
|
`export const live = { state, on }`; buttons use `data-live="handler"` instead
|
|
107
113
|
of `onClick`. State lives on the server; the server pushes HTML patches.
|
|
114
|
+
Forms use `data-live-submit="handler"` (gets the fields as an object), inputs
|
|
115
|
+
`data-live-input` (debounced; `data-live-debounce="ms"`) or `data-live-change`;
|
|
116
|
+
give list rows `data-key`. Read the request with `getContext()` and guard
|
|
117
|
+
events with `live.authorize`; `live.subscribe` + `live.load` + `publish(topic)`
|
|
118
|
+
push server-side changes. `live.room(props)` + `live.shared()` share one state
|
|
119
|
+
between everyone in a room (`data-nowaki-presence="<room>"` shows who's there).
|
|
120
|
+
Rooms, `publish`, and presence live in one server process (`nowaki start`);
|
|
121
|
+
on the deploy adapters live islands work per event over POST, without push.
|
|
108
122
|
9. **Loading / error UI** (client navigation) — `routes/loading.tsx` renders
|
|
109
123
|
while a navigation is in flight; `routes/error.tsx` (props `{ error, reset }`,
|
|
110
124
|
type `ErrorPageProps`) renders if it fails. Both nest by directory. In
|
|
@@ -129,6 +143,17 @@ nowaki.config.mjs plugins (optional)
|
|
|
129
143
|
`.env.example` to `.env` and keep database URLs, API keys, and tokens unprefixed.
|
|
130
144
|
- **Server functions and API routes are public endpoints.** Validate and bound every
|
|
131
145
|
argument; authorize with `getContext()` (cookies/headers) before mutating data.
|
|
146
|
+
Use `serverFn(schema, impl)` for `"use server"` exports that take arguments (see
|
|
147
|
+
`actions/echo.ts` in the **basics** template).
|
|
148
|
+
- **Cross-site writes.** Page `action`s reject cross-site non-GET requests by default.
|
|
149
|
+
**`routes/_middleware.ts` runs before that check** — do not perform sensitive
|
|
150
|
+
mutations in middleware unless you validate the caller yourself. API routes log a
|
|
151
|
+
warning and still accept cross-site POSTs unless you `export const csrf = true` on
|
|
152
|
+
the route (recommended for cookie-authenticated APIs).
|
|
153
|
+
- **Production checklist** (when you deploy): set `NOWAKI_LIVE_SECRET` if the app
|
|
154
|
+
uses Jetstream live islands; try `NOWAKI_CSP=report-only` before `enforce`; behind
|
|
155
|
+
a reverse proxy on `nowaki start`, set `NOWAKI_TRUST_PROXY=1` and forward the public
|
|
156
|
+
host as `x-forwarded-host`. See the upstream [SECURITY.md](https://github.com/Tettu0530/nowaki/blob/main/SECURITY.md).
|
|
132
157
|
- **Do not embed secrets** in client islands, loaders returned to the page, or static
|
|
133
158
|
prerender output. ISR pages must not include per-user secrets.
|
|
134
159
|
|
|
@@ -44,7 +44,15 @@ actions/ "use server" RPC modules (optional)
|
|
|
44
44
|
`preact/compat`, so many React libraries work.)
|
|
45
45
|
- Use **explicit file extensions** in relative imports: `../islands/Counter.tsx`.
|
|
46
46
|
- A route's `loader` runs only on the server; `action` handles non-GET requests.
|
|
47
|
-
-
|
|
48
|
-
|
|
47
|
+
- The **basics** template adds `routes/_404.tsx`, `routes/api/health.ts`, and
|
|
48
|
+
`actions/echo.ts`; **minimal** is a single page with no islands.
|
|
49
|
+
- `AGENTS.md` documents conventions (including security) for AI coding agents.
|
|
50
|
+
|
|
51
|
+
## Production
|
|
52
|
+
|
|
53
|
+
Use `npm run build` then `npm run start` (or a deploy adapter). Do not run
|
|
54
|
+
`nowaki dev` on the public internet. Cookie-authenticated API routes should export
|
|
55
|
+
`csrf = true`; live islands need a stable `NOWAKI_LIVE_SECRET`. See `AGENTS.md`
|
|
56
|
+
§ Security and [nowaki.dev/docs](https://nowaki.dev/docs).
|
|
49
57
|
|
|
50
58
|
Docs: <https://nowaki.dev/docs>
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
"prerender": "nowaki prerender"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@nowaki-dev/runtime": "^0.
|
|
12
|
+
"@nowaki-dev/runtime": "^0.15.0",
|
|
13
13
|
"preact": "^10.25.4",
|
|
14
14
|
"preact-render-to-string": "^6.8.2"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"nowaki": "^0.
|
|
17
|
+
"nowaki": "^0.16.0"
|
|
18
18
|
}
|
|
19
19
|
}
|