create-nowaki 0.15.0 → 0.16.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nowaki",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Scaffold a new Nowaki app",
5
5
  "license": "MIT",
6
6
  "author": "Tettu0530",
@@ -105,6 +105,14 @@ nowaki.config.mjs plugins (optional)
105
105
  8. **Jetstream islands** (server-reactive, zero client JS) — give an island
106
106
  `export const live = { state, on }`; buttons use `data-live="handler"` instead
107
107
  of `onClick`. State lives on the server; the server pushes HTML patches.
108
+ Forms use `data-live-submit="handler"` (gets the fields as an object), inputs
109
+ `data-live-input` (debounced; `data-live-debounce="ms"`) or `data-live-change`;
110
+ give list rows `data-key`. Read the request with `getContext()` and guard
111
+ events with `live.authorize`; `live.subscribe` + `live.load` + `publish(topic)`
112
+ push server-side changes. `live.room(props)` + `live.shared()` share one state
113
+ between everyone in a room (`data-nowaki-presence="<room>"` shows who's there).
114
+ Rooms, `publish`, and presence live in one server process (`nowaki start`);
115
+ on the deploy adapters live islands work per event over POST, without push.
108
116
  9. **Loading / error UI** (client navigation) — `routes/loading.tsx` renders
109
117
  while a navigation is in flight; `routes/error.tsx` (props `{ error, reset }`,
110
118
  type `ErrorPageProps`) renders if it fails. Both nest by directory. In
@@ -129,6 +137,17 @@ nowaki.config.mjs plugins (optional)
129
137
  `.env.example` to `.env` and keep database URLs, API keys, and tokens unprefixed.
130
138
  - **Server functions and API routes are public endpoints.** Validate and bound every
131
139
  argument; authorize with `getContext()` (cookies/headers) before mutating data.
140
+ Use `serverFn(schema, impl)` for `"use server"` exports that take arguments (see
141
+ `actions/echo.ts` in the **basics** template).
142
+ - **Cross-site writes.** Page `action`s reject cross-site non-GET requests by default.
143
+ **`routes/_middleware.ts` runs before that check** — do not perform sensitive
144
+ mutations in middleware unless you validate the caller yourself. API routes log a
145
+ warning and still accept cross-site POSTs unless you `export const csrf = true` on
146
+ the route (recommended for cookie-authenticated APIs).
147
+ - **Production checklist** (when you deploy): set `NOWAKI_LIVE_SECRET` if the app
148
+ uses Jetstream live islands; try `NOWAKI_CSP=report-only` before `enforce`; behind
149
+ a reverse proxy on `nowaki start`, set `NOWAKI_TRUST_PROXY=1` and forward the public
150
+ host as `x-forwarded-host`. See the upstream [SECURITY.md](https://github.com/Tettu0530/nowaki/blob/main/SECURITY.md).
132
151
  - **Do not embed secrets** in client islands, loaders returned to the page, or static
133
152
  prerender output. ISR pages must not include per-user secrets.
134
153
 
@@ -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
- - `routes/api/health.ts` is a minimal JSON API example; `routes/_404.tsx` handles unknown paths.
48
- - `AGENTS.md` documents the conventions for AI coding agents.
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.13.0",
12
+ "@nowaki-dev/runtime": "^0.14.0",
13
13
  "preact": "^10.25.4",
14
14
  "preact-render-to-string": "^6.8.2"
15
15
  },
16
16
  "devDependencies": {
17
- "nowaki": "^0.14.0"
17
+ "nowaki": "^0.15.0"
18
18
  }
19
19
  }