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 08f4164
Browse filesBrowse the repository at this point in the historyBrowse files
-**Header values** use `Name: value` format. The value may contain colons.
25
25
- All matching rules are merged. When multiple rules set the same header name, the **last match wins**.
26
26
- User-defined `Cache-Control` overrides the built-in default. The default still applies when no rule matches.
27
+
- With [authentication](../auth.md), responses to requests that send cookies or credentials stay private, and auth endpoints stay uncached, during local development, with `void deploy --platform cloudflare`, and on [other runtimes](../deployment.md#other-runtimes). On a [Void platform](../deployment.md#deploy-to-a-team-platform), a `Cache-Control` rule replaces the app's value, so do not match signed-in pages or `/api/auth/*` with a public cache rule.
28
+
- Rules apply to matching error responses too, including 404 responses. An immutable cache rule can therefore cache a missing file. Use immutable caching only for URLs that change when their content changes.
Copy file name to clipboardExpand all lines: docs/guide/edge/rewrites.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
@@ -56,7 +56,7 @@ Keep access checks on any destination that needs them.
56
56
57
57
A destination without `?` preserves the incoming query string. `c.rewrite('/search')` keeps `?q=...`, while `c.rewrite('/search?q=all')` replaces it.
58
58
59
-
Your editor suggests known routes through the [`RewriteDestination`](../../reference/api/rewrites.md#rewritedestination) type. Dynamic strings are also accepted.
59
+
Your editor suggests known routes through the [`RewriteDestination`](../../reference/api/rewrites.md#rewritedestination) type. Dynamic strings are also accepted. With [`routing.typedRoutes`](../../reference/config.md#routing-typedroutes), a string must match one of your routes; add `as RouteUrl` to a path built at runtime, such as ``c.rewrite(`/en${c.req.path}` as RouteUrl)``.
`replyEmail()` replies to the original sender with a threaded subject. You can override `subject`.
81
+
`replyEmail()` replies to the original sender with a threaded subject. You can override `subject`. To reply after the handler returns, use [`sendEmail` with `threading`](./sending.md#reply-later).
82
82
83
83
On a Void platform, the default sender is your project's shared address, or the address that received mail on your registered domain. Use that default for shared mail; `message.to` has the project prefix removed. Sender overrides must belong to your project.
|`threading`|`{ inReplyTo?, references? }`| Optional. Threads the email under an earlier message. See [Reply later](#reply-later). |
81
+
|`attachments`|`Attachment[]`| See [Attachments](#attachments). |
82
+
|`idempotencyKey`|`string`| Optional on the Void Platform: 1–128 printable, non-space ASCII characters. Reuse for retries of the same send. |
82
83
83
84
You can send to at most 50 recipients across `to`, `cc`, and `bcc`. Use standard email addresses with ASCII local parts, and punycode for internationalized domains.
84
85
@@ -88,6 +89,35 @@ On the platform the sender is pinned to your project. `from` must be your projec
88
89
89
90
On your own Cloudflare account, `from` defaults to `email.from` from `void.config.ts` and must be on a domain your account can send from; Cloudflare rejects any other sender and `sendEmail` reports it as `INVALID_FROM`.
90
91
92
+
## Reply later {#reply-later}
93
+
94
+
`replyEmail()` works only while the inbound handler runs. To reply later, for example from a queue job, save the thread ids in the handler and pass them to `sendEmail` as `threading`:
`inReplyTo` is the parent message's `Message-ID`. `references` lists the thread's ids, oldest first, ending with the parent; it defaults to `inReplyTo`. Mail clients use them to show the reply in the same conversation. An id that cannot be sent, such as one with a control character, is left out. If `references` cannot be sent, it falls back to `inReplyTo`. The email still sends. `headers` cannot set `In-Reply-To` or `References`.
| Nothing (void) | Re-runs the loader, page re-renders with fresh props. |
30
30
|`c.redirect('/path')`| Navigates to another page. |
31
31
32
+
Middleware does not run again after the action. To change [shared data](./layouts.md#shared-data), update it in the action or redirect.
33
+
32
34
## Form
33
35
34
36
Pair `Form` with `useForm` to submit values and display validation and action errors. Inputs stay editable when a submission fails.
@@ -196,6 +198,8 @@ const form = useForm(
196
198
197
199
`onError` receives a field-error map or a `VoidActionError`. Callbacks can be async; `form.pending` stays true until they finish, and thrown errors reach the nearest React error boundary. Callbacks run before React commits the updated UI, so use an effect or ref callback to focus an element that appears after submission.
198
200
201
+
If a callback awaits `router.visit()` or `router.refresh()`, pass `{ resolveOn: 'data' }` so it can finish before React commits the navigation. See [React navigation completion](../../reference/api/pages.md#react-navigation-completion).
202
+
199
203
Vue, Svelte, and Solid submissions return a promise instead; use `await form.post()` to run work after a submission.
200
204
201
205
## Named Actions
@@ -270,7 +274,7 @@ if (!result.ok) {
270
274
271
275
`action()` defaults to `POST`. Pass `data`, `params`, and `method` to set the body, route parameters, or HTTP method.
272
276
273
-
A successful call returns `{ ok: true, pageData }`. Expected errors, such as validation failures or conflicts, return `{ ok: false, error }`.
277
+
A successful call returns `{ ok: true, pageData }`. Expected errors, such as validation failures or conflicts, return `{ ok: false, error }`.`error.message` is the message of an [`HTTPException`](../../integrations/hono.md#utilities) with a `4xx` status, or the body of another plain-text `4xx` response. For other errors, it is a status summary such as `Action failed with 404 Not Found`.
Call `useShared()` from your framework adapter, as in the layout examples above. Its return type is inferred from `CloudContextVariables`. Shared data comes from middleware; page props come from the loader. See [Context variables](../type-safety.md#context-variables).
241
+
Call `useShared()` from your framework adapter, as in the layout examples above. Its return type is inferred from `CloudContextVariables`. See [Context variables](../type-safety.md#context-variables).
242
+
243
+
Middleware sets the starting value. A loader or action can update it before the page is sent:
244
+
245
+
```ts
246
+
// pages/profile.server.ts
247
+
import { defineHandler } from'void';
248
+
249
+
exportconst action =defineHandler(async (c) => {
250
+
const user =awaitupdateProfile(c);
251
+
c.set('shared', { ...c.get('shared'), auth: { user } });
252
+
});
253
+
```
254
+
255
+
Middleware runs before the action. If an action changes data that shared data is built from, update shared data in the action, or redirect with `c.redirect()` so middleware runs again on the next page load.
Copy file name to clipboardExpand all lines: docs/guide/pages-routing/overview.md
+84Lines changed: 84 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -199,6 +199,8 @@ import { routeUrl } from 'void/routes';
199
199
200
200
:::
201
201
202
+
With [`routing.typedRoutes`](../type-safety.md#checked-url-strings), which apps created with `void init` have on, `href` and the router methods below reject plain strings such as `"/user"` that don't match a route.
203
+
202
204
`Link` also supports query data, history replacement, full-page navigation, and cancellation:
203
205
204
206
```tsx
@@ -263,6 +265,88 @@ export default function PostPage() {
263
265
}
264
266
```
265
267
268
+
### Active links
269
+
270
+
`Link` marks the link to the current page with `aria-current="page"` and `data-void-active`. Use them to style navigation:
271
+
272
+
```css
273
+
nava[data-void-active] {
274
+
font-weight: 600;
275
+
}
276
+
```
277
+
278
+
A link is active only on its own path by default. Set `activeMatch="prefix"` to keep it active on nested pages:
|`/users?page=2`| both attributes | both attributes |
320
+
|`/users/42`| none |`data-void-active`|
321
+
|`/users-admin`| none | none |
322
+
323
+
`aria-current="page"` marks only the exact page, so select `[aria-current="page"]` to style it differently from its section. A link to `/` is active only on the home page.
324
+
325
+
Paths match the way pages are routed: letter case and trailing slashes count, while the query string and hash are ignored. Links to other origins and non-GET links are never active. An `aria-current` or `data-void-active` you pass to `Link` replaces the computed value.
326
+
327
+
### Prefetching
328
+
329
+
Add `prefetch` to a `Link` to load its page before the user clicks, so the visit doesn't wait for the server:
330
+
331
+
```tsx
332
+
<Linkhref="/dashboard"prefetch>
333
+
Dashboard
334
+
</Link>
335
+
```
336
+
337
+
`prefetch` on its own loads the page on hover, keyboard focus, or touch. A `Link` can also prefetch on click, as soon as it renders, or when it scrolls into view, and `cacheFor` sets how long a prefetched page is reused. See [Prefetching](../../reference/api/pages.md#prefetching) for every option.
338
+
339
+
To give every `Link` a prefetch strategy, set `prefetch.defaultStrategy` in the adapter plugin. A `Link` that sets its own `prefetch` keeps it:
Prefer `'hover'` or `'click'` as the default. With `'mount'` or `'visible'`, every `Link` loads its page as soon as it renders or scrolls into view, including links in long lists.
347
+
348
+
Prefetching runs the destination's loader, so keep loaders free of side effects such as counting views.
349
+
266
350
## Scroll Restoration
267
351
268
352
Void manages scroll position for Pages automatically:
0 commit comments