You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c192892
Browse filesBrowse the repository at this point in the historyBrowse files
Create forms often need empty fields again after a successful save. Either pass `resetOnSuccess: true` in the third argument, or call `form.reset({ initial: true })` when `form.wasSuccessful` becomes `true`.
179
179
180
+
### React submission callbacks
181
+
182
+
In React, pass `onSuccess` and `onError` to `useForm()` to respond to a submission:
183
+
184
+
```tsx
185
+
const form =useForm(
186
+
'/users',
187
+
{ name: '', email: '' },
188
+
{
189
+
onSuccess: () =>setDialogOpen(false),
190
+
onError: (error) => {
191
+
// A field-error map or VoidActionError for a handled action failure.
192
+
console.error(error);
193
+
},
194
+
},
195
+
);
196
+
```
197
+
198
+
Each submission uses the callbacks from when it was dispatched. Callbacks run inside the React Action, before the updated UI commits. Use an effect or ref callback to focus an element that appears after submission.
199
+
200
+
Callbacks can return `Promise<void>`. The Action awaits them, and `form.pending` stays true until they complete. Errors thrown or rejected by callbacks reach the nearest React error boundary. Aborted submissions invoke neither callback.
201
+
202
+
Vue, Svelte, and Solid submissions return a promise instead; use `await form.post()` to run work after a submission.
203
+
180
204
## Named Actions
181
205
182
206
When a page needs multiple mutations, such as updating and deleting a user on the same page, export `actions` (plural) instead of `action`:
Copy file name to clipboardExpand all lines: docs/guide/platform/installation/maintenance.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,7 +100,9 @@ Repair recreates missing infrastructure that the installer owns. It does not res
100
100
101
101
### Upgrade the platform
102
102
103
-
Keep the platform runtime current when updating the Void CLI.
103
+
Keep the platform runtime current when updating the Void CLI. Upgrade the platform before your team updates its CLI: a newer CLI refuses to work with an older platform and asks for `void platform upgrade`. Install the new CLI on the administrator's machine, run the upgrade below, then have the team update.
104
+
105
+
If the platform will deploy apps that use `void/sandbox`, its runtime token needs **Account → Containers → Edit** and **Account → Cloudchamber → Edit**. A token made from an older setup link may lack them, and an upgrade does not add them. Edit the token in the Cloudflare dashboard, or set `VOID_PLATFORM_RUNTIME_CLOUDFLARE_API_TOKEN` to a new token when you upgrade. See [Cloudflare API Tokens](/guide/platform/installation/credentials#runtime-token-permissions).
104
106
105
107
Use the installed CLI's packaged runtime to upgrade:
Copy file name to clipboardExpand all lines: docs/guide/ssg.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,14 @@ export async function getPrerenderPaths() {
37
37
}
38
38
```
39
39
40
+
## 404 pages
41
+
42
+
Static builds that prerender at least one page include a default `404.html` in `dist/client/`. To provide your own, add `public/404.html` or prerender a page at `/404`.
43
+
44
+
Fully static Void deployments serve this page for missing URLs with an HTTP 404 status by default. You can override this with [`routing.notFound`](../reference/config.md#routing-notfound). Hybrid deployments handle missing URLs in the Worker.
45
+
46
+
When hosting `dist/client/` yourself, configure your host to serve `404.html` with a 404 status for missing pages.
Copy file name to clipboardExpand all lines: docs/reference/api/pages.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,6 +109,8 @@ Imported from `"@void/react"`.
109
109
110
110
React `Link` GET `data` is merged into the rendered `href` query string. Primitive values are serialized with `String(value)`, arrays become repeated keys, `null` and `undefined` are omitted, and nested objects throw. `prefetch` and `reloadDocument` are GET-only and throw for mutation links.
111
111
112
+
React `useForm()` options accept `onSuccess?: () => void | Promise<void>` and `onError?: (error: Record<string, string> | VoidActionError) => void | Promise<void>`. Each submission captures its callbacks, runs them before the updated UI commits, and awaits any returned promise. See [submission callbacks](../../guide/pages-routing/actions-and-forms.md#react-submission-callbacks).
113
+
112
114
React deferred props returned from `defer()` are Suspense resources. Read them
113
115
with React's `use()` inside a `<Suspense>` boundary. React Pages requires React
114
116
19 and uses streaming SSR for the initial deferred shell. Rejections throw from
Copy file name to clipboardExpand all lines: docs/reference/config.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -297,7 +297,7 @@ Void-managed WebSocket route files (`*.ws.ts`) are Cloudflare-only because they
297
297
298
298
### `worker`
299
299
300
-
Curated Cloudflare Workers configuration. `void init` pins `compatibility_date` here. Binding arrays such as `d1_databases`, `kv_namespaces`, and `r2_buckets` go in [`cloudflare`](#cloudflare), where Void preserves custom settings and resolved IDs during deployment.
300
+
Curated Cloudflare Workers configuration. `void init` pins `compatibility_date` here. If a project has no config file and no date, the first dev server or build creates `void.config.ts` with only this date and adds `.void-wrangler.jsonc` to `.gitignore`. Astro, SvelteKit, Nuxt, and Analog apps get the date in a root `wrangler.jsonc` instead, which their adapter reads by default. A project with a `wrangler.toml` gets it in `void.json`. Binding arrays such as `d1_databases`, `kv_namespaces`, and `r2_buckets` go in [`cloudflare`](#cloudflare), where Void preserves custom settings and resolved IDs during deployment.
0 commit comments