Skip to content

Commit c192892

Browse files
committed
Merge branch 'main' into fix/log-queue-handler-errors
2 parents db9bb2e + 4f1eaee commit c192892

32 files changed

Lines changed: 889 additions & 173 deletions

‎docs/guide/pages-routing/actions-and-forms.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,30 @@ const form = useForm('/users/:id', { name: '' }, { params: { id: '42' } });
177177

178178
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`.
179179

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+
180204
## Named Actions
181205

182206
When a page needs multiple mutations, such as updating and deleting a user on the same page, export `actions` (plural) instead of `action`:

‎docs/guide/platform/installation/maintenance.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ Repair recreates missing infrastructure that the installer owns. It does not res
100100

101101
### Upgrade the platform
102102

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).
104106

105107
Use the installed CLI's packaged runtime to upgrade:
106108

‎docs/guide/ssg.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ export async function getPrerenderPaths() {
3737
}
3838
```
3939

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.
47+
4048
## Comparison with edge prerendering
4149

4250
| `output` value | Default prerender | Per-page override | Prerender timing |

‎docs/reference/api/pages.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ Imported from `"@void/react"`.
109109

110110
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.
111111

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+
112114
React deferred props returned from `defer()` are Suspense resources. Read them
113115
with React's `use()` inside a `<Suspense>` boundary. React Pages requires React
114116
19 and uses streaming SSR for the initial deferred shell. Rejections throw from

‎docs/reference/config.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ Void-managed WebSocket route files (`*.ws.ts`) are Cloudflare-only because they
297297

298298
### `worker`
299299

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.
301301

302302
| Field | Type | Description |
303303
| --------------------- | ---------- | -------------------------------------- |

‎packages/deploy-cloudflare/src/version.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export type CloudflareTriggerConfig = Readonly<{
5050
queueConsumers: ReadonlyArray<unknown>;
5151
workflows: ReadonlyArray<unknown>;
5252
/**
53-
* Email Routing addresses (`addresses` in Wrangler config). Wrangler 4.131 applies its
53+
* Email Routing addresses (`addresses` in Wrangler config). The Cloudflare CLI applies its
5454
* Email Routing plan inside `triggers deploy` — `undefined` skips the plan entirely, while
5555
* `[]` is a destructive plan that deletes every rule this Worker owns — so the two must stay
5656
* distinct through the snapshot. Absent from annotations written before this field existed.

‎packages/deploy-cloudflare/test/unit/version.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,7 @@ describe('Cloudflare version activation', () => {
17131713
).not.toHaveProperty('contentHash');
17141714
});
17151715

1716-
// Wrangler 4.131 applies its Email Routing plan inside `triggers deploy`, reading the
1716+
// The Cloudflare CLI applies its Email Routing plan inside `triggers deploy`, reading the
17171717
// config's `addresses`. The trigger-only config Void hands it must therefore carry the
17181718
// snapshot's addresses verbatim — and carry NOTHING when the snapshot has none, because an
17191719
// absent key skips the plan while `[]` deletes every rule the Worker owns.

‎packages/react/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"@types/node": "catalog:",
5050
"@types/react": "^19.3.0",
5151
"@types/react-dom": "^19.3.0",
52+
"happy-dom": "catalog:",
5253
"pathslash": "catalog:",
5354
"react": "catalog:",
5455
"react-dom": "catalog:",

‎packages/react/src/runtime/use-form.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,18 @@ type UntypedForm = {
4242
clearError(): void;
4343
};
4444

45+
type FormOptions = {
46+
params?: Record<string, string>;
47+
resetOnSuccess?: boolean;
48+
onSuccess?: () => void | Promise<void>;
49+
onError?: (error: Record<string, string> | VoidActionError) => void | Promise<void>;
50+
};
51+
4552
// Typed overload — full inference from PageActionMap (requires codegen)
4653
export function useForm<U extends ActionUrl & string>(
4754
url: U,
4855
defaults: ResolveActionBody<U>,
49-
options?: ActionFormOptions<U>,
56+
options?: ActionFormOptions<U> & Pick<FormOptions, 'onSuccess' | 'onError'>,
5057
): {
5158
data: ResolveActionBody<U>;
5259
setData: <K extends keyof ResolveActionBody<U> & string>(
@@ -76,7 +83,7 @@ export function useForm<U extends ActionUrl & string>(
7683
export function useForm(
7784
url: string,
7885
defaults: Record<string, unknown>,
79-
options?: { params?: Record<string, string>; resetOnSuccess?: boolean },
86+
options?: FormOptions,
8087
): UntypedForm {
8188
const router = useContext(RouterContext);
8289
const [data, setDataState] = useState<Record<string, unknown>>(() => cloneFormValue(defaults));
@@ -186,8 +193,10 @@ export function useForm(
186193
const validationErrors = getValidationErrors(result.error.body);
187194
if (validationErrors) {
188195
setErrors(validationErrors);
196+
await options?.onError?.(validationErrors);
189197
} else {
190198
setActionError(result.error);
199+
await options?.onError?.(result.error);
191200
}
192201
return previousSuccessVersion;
193202
}
@@ -205,6 +214,7 @@ export function useForm(
205214
setRecentlySuccessful(false);
206215
successTimeoutRef.current = null;
207216
}, 2000);
217+
await options?.onSuccess?.();
208218
return previousSuccessVersion + 1;
209219
},
210220
0,

0 commit comments

Comments
 (0)