Full create, read, update, delete — from HTML forms, no backend code.
Declare a fetch.* directive in the <what> block. The local: prefix queries your configured database. The result is available as a template variable.
<what>
fetch.notes = "local:notes?sort=created_at:desc&limit=20"
</what>
<loop data="#notes#" as="note">
<div>#note.title#</div>
</loop>
Use action="/w-action/notes" with method="post" to insert a new record. The form fields become the record's columns.
Records are fetched via fetch.notes = "local:notes" in the <what> block at the top of this page.
| Action | Form action | Method |
|---|---|---|
| Create record | /w-action/notes |
POST |
| Update record | /w-action/notes/#id# |
POST |
| Delete record | /w-action/notes/#id#?w-action=delete |
POST |
Forms can send data to different destinations depending on the action URL:
| Destination | How |
|---|---|
| Database | action="/w-action/collection" — persists to SQLite/D1 |
| Session | w-set="session.key = $value" — per-user, no form submit needed |
| App state | w-set="app.key = $value" — shared across all users |
| Wired (real-time) | w-set="wired.key = $value" — broadcasts to all browsers via WebSocket |
Every <form method="post"> automatically gets a hidden CSRF token injected by the engine. You don't need to add it manually — it's built in.
<!-- You write this: -->
<form method="post" action="/w-action/notes">
<input name="title">
<button type="submit">Save</button>
</form>
<!-- The engine renders this: -->
<form method="post" action="/w-action/notes">
<input type="hidden" name="_csrf" value="auto-generated-token">
<input name="title">
<button type="submit">Save</button>
</form>
<!-- Sort, filter, search, paginate -->
fetch.notes = "local:notes?sort=created_at:desc&limit=10&offset=0"
fetch.active = "local:items?filter=status:active"
fetch.results = "local:posts?search=hello"
fetch.name = "local:collection" queries your SQLite database#name# and iterated with <loop>POST /w-action/collection — form fields become columnsPOST /w-action/collection/#id#POST /w-action/collection/#id#?w-action=deletesort, filter, search, limit, offset/w-action/), session, app state, or wired (real-time)