void 1.8.0 → 1.9.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/dist/{account-cmd-CZKntRH2.mjs → account-cmd-BEMOdwtl.mjs} +3 -3
- package/dist/{application-analysis-CyTagJQM.mjs → application-analysis-3VVsflWZ.mjs} +5 -5
- package/dist/{application-routing-BLrMVpqi.mjs → application-routing-CJRlXCc2.mjs} +1 -1
- package/dist/{auth-Bk9VGtQW.d.mts → auth-CV9kXHKe.d.mts} +3 -1
- package/dist/{auth-DyWp-fSo.mjs → auth-aMuFOZeI.mjs} +8 -2
- package/dist/{auth-link-BOaQWMKw.mjs → auth-link-B1IynRW5.mjs} +3 -3
- package/dist/{auth-router-D0-VcmDs.mjs → auth-router-DVaWJdRB.mjs} +2 -2
- package/dist/{better-auth-shared-CdVyCUou.mjs → better-auth-shared-C7LHvF4L.mjs} +1 -1
- package/dist/{better-auth-shared-CQFdtguU.d.mts → better-auth-shared-ajs3LNrY.d.mts} +1 -1
- package/dist/{build-cmd-JTsXXf2F.mjs → build-cmd-Dq8tdqQG.mjs} +1 -1
- package/dist/{cache-D0m3Z_Xf.mjs → cache-DGMnskX7.mjs} +1 -1
- package/dist/{cancel-deploy-Ce6Os4fa.mjs → cancel-deploy-96S5hD1E.mjs} +1 -1
- package/dist/cli/cli.mjs +1 -1
- package/dist/cli/env-schema-probe.mjs +3 -3
- package/dist/{cli-main-rkrJy2Ge.mjs → cli-main-CQRLxZAu.mjs} +28 -28
- package/dist/client-66c0RLDM.mjs +1 -0
- package/dist/{client-SZPyj4X_.mjs → client-D6w5x7hM.mjs} +7 -7
- package/dist/{cloudflare-auth-7jTqy9Bx.mjs → cloudflare-auth-pNvmT6kL.mjs} +1 -1
- package/dist/{cloudflare-cmd-ChPLQcTP.mjs → cloudflare-cmd-BuuHUM4z.mjs} +3 -3
- package/dist/{cloudflare-config-DtOGAbeB.mjs → cloudflare-config-PxbinLLE.mjs} +2 -2
- package/dist/{cloudflare-connect-Co93VYTo.mjs → cloudflare-connect-D1QOosLd.mjs} +2 -2
- package/dist/{cloudflare-operations-CXaDKYj2.mjs → cloudflare-operations-G5AObYzF.mjs} +5 -5
- package/dist/{cloudflare-operations-DATekLwI.mjs → cloudflare-operations-I4t3mt4R.mjs} +1 -1
- package/dist/{cloudflare-process-DmTxZR-N.mjs → cloudflare-process-wcnaQ5JG.mjs} +2 -2
- package/dist/{config-wo2EaH0X.mjs → config-C1DPf8EK.mjs} +1 -1
- package/dist/{config-CTlUaXWZ.d.mts → config-CCWVY7DY.d.mts} +1 -1
- package/dist/{config-5oSQhZNj.mjs → config-CzFdJYNA.mjs} +1 -1
- package/dist/{config-DcqUBGCb.mjs → config-DlWQ_hIJ.mjs} +3 -3
- package/dist/{config-eeDzKBS9.mjs → config-Do7gJI3T.mjs} +2 -2
- package/dist/config-entry.d.mts +1 -1
- package/dist/{connect-DlvXt1JR.mjs → connect-4uImOwut.mjs} +4 -4
- package/dist/{create-project-CC_7hmYJ.mjs → create-project-BaUzZnLZ.mjs} +1 -1
- package/dist/{create-project-DzY05xqC.mjs → create-project-CQMyzTvK.mjs} +1 -1
- package/dist/{db-FhyYGcJJ.mjs → db-DEpDeDsi.mjs} +19 -19
- package/dist/{db-types-sVwEpyPR.mjs → db-types-BpPYAx0B.mjs} +1 -1
- package/dist/{delete-CModjyOC.mjs → delete-BVD2kI82.mjs} +1 -1
- package/dist/deploy-Dr_Qamzw.mjs +2 -0
- package/dist/{deploy-Cz9TEzZy.mjs → deploy-Dyeo5soA.mjs} +24 -75
- package/dist/{deploy-managed-static-DlxxXkAM.mjs → deploy-managed-static-Kn73R83A.mjs} +20 -20
- package/dist/{deploy-transport-DUvm6-CR.mjs → deploy-transport-BpKBs_KR.mjs} +2 -2
- package/dist/deploy.mjs +6 -6
- package/dist/discover-Diq0l6TZ.mjs +1 -0
- package/dist/{discover-CVFCWU7W.mjs → discover-Vd18lHsj.mjs} +1 -1
- package/dist/{dispatch-CCiaAnSK.mjs → dispatch-BBfb519j.mjs} +5 -5
- package/dist/{domain-DvdZPA50.mjs → domain-BTIdyUVk.mjs} +2 -2
- package/dist/{email-ASpNrfLd.mjs → email-DvrS-I0U.mjs} +7 -7
- package/dist/{email-cloudflare-kqoN9jst.mjs → email-cloudflare-DAGpgzY1.mjs} +3 -3
- package/dist/{entry-BweGTCgj.mjs → entry-DMgR7XOf.mjs} +1 -1
- package/dist/{env-Bpkg3G5i.mjs → env-D7vORwpn.mjs} +4 -4
- package/dist/{env-types-Dz9qkiOn.mjs → env-types-WEZw5D-r.mjs} +1 -1
- package/dist/{env-validation-CN386Utu.mjs → env-validation-DKDcpxbt.mjs} +1 -1
- package/dist/{env-validation-BpCCQE_6.mjs → env-validation-DeYNRp1d.mjs} +3 -3
- package/dist/{gen-upKJChvd.mjs → gen-DimkGNve.mjs} +4 -4
- package/dist/gen-DmEeVEs4.mjs +1 -0
- package/dist/{github-cmd-BvMOlb8Z.mjs → github-cmd-D-zs6VQr.mjs} +1 -1
- package/dist/{handler-BO7Od-z9.d.mts → handler-6fzr_ikp.d.mts} +3 -3
- package/dist/{head-MeF_5M_3.d.mts → head-CVO92KEx.d.mts} +14 -3
- package/dist/{head-5XPcnG-j.mjs → head-CWJhfUwV.mjs} +62 -3
- package/dist/{headers-COGEDoMN.mjs → headers-Q0kZDpk8.mjs} +1 -1
- package/dist/{help-TPCjTu6e.mjs → help-Cgdcd-SG.mjs} +4 -4
- package/dist/help-Cp3K5m1w.mjs +1 -0
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +23 -23
- package/dist/{info-EsDyihwf.mjs → info-BbxQ34kk.mjs} +4 -4
- package/dist/{init-a4lVagrb.mjs → init-zyRj3QRw.mjs} +14 -14
- package/dist/{link-CE55DDzS.mjs → link-DAFXuIER.mjs} +2 -2
- package/dist/{list-CxRthQks.mjs → list-BTIcC3W9.mjs} +2 -2
- package/dist/{live-Kc55iuOQ.d.mts → live-DBybyDt0.d.mts} +2 -2
- package/dist/{live-CYJ4KGoR.mjs → live-Dw7NF1t2.mjs} +1 -1
- package/dist/load-user-env-ztmIyiLx.mjs +34 -0
- package/dist/{local-d1-CFcH9Bx3.mjs → local-d1-BnVb7Fem.mjs} +1 -1
- package/dist/login-DBs8JuSl.mjs +1 -0
- package/dist/{login-AfcSGSmE.mjs → login-DOE-MkeK.mjs} +2 -2
- package/dist/{logs-BgRJuvb1.mjs → logs-CUsjihc3.mjs} +2 -2
- package/dist/migrate-BYhoIK9R.mjs +1 -0
- package/dist/{migrate-BNAh6m_C.mjs → migrate-DtoKdGas.mjs} +4 -4
- package/dist/nitro.mjs +3 -3
- package/dist/{node-CXFUw0Uz.mjs → node-D9dPyUr0.mjs} +2 -2
- package/dist/operator-ai-logging-DFTEp81Z.mjs +121 -0
- package/dist/{operator-args-DGTuCdSE.mjs → operator-args-BCCohcz3.mjs} +3 -2
- package/dist/{operator-cmd-C-viB7Si.mjs → operator-cmd-CQOQrUiO.mjs} +26 -6
- package/dist/operator-cmd-xCACDtT1.mjs +1 -0
- package/dist/pages/client.d.mts +1 -1
- package/dist/pages/client.mjs +15 -13
- package/dist/pages/head.d.mts +2 -2
- package/dist/pages/head.mjs +1 -1
- package/dist/pages/index.d.mts +2 -2
- package/dist/pages/index.mjs +5 -5
- package/dist/pages/islands-plugin.d.mts +5 -1
- package/dist/pages/islands-plugin.mjs +6 -2
- package/dist/pages/protocol.d.mts +2 -2
- package/dist/pages/protocol.mjs +1 -1
- package/dist/platform-args-DSi4_M8n.mjs +1 -0
- package/dist/{platform-args-CiYeZmc5.mjs → platform-args-DtpHS_75.mjs} +1 -1
- package/dist/{platform-auth-config-Dt2qEc2w.mjs → platform-auth-config-fLwIS5VG.mjs} +3 -3
- package/dist/{platform-auth-protection-B7TaF-PZ.mjs → platform-auth-protection-BTRI_YwD.mjs} +2 -2
- package/dist/{platform-auth-recovery-suXSteJ6.mjs → platform-auth-recovery-DPK2Mvmo.mjs} +2 -2
- package/dist/{platform-cmd-DuAsIxbU.mjs → platform-cmd-BLy5uCa-.mjs} +1 -1
- package/dist/{platform-cmd-9rvYBBtr.mjs → platform-cmd-HS_FSthn.mjs} +5 -5
- package/dist/{platform-domain-DhH_vDr6.mjs → platform-domain-CHpcq_qg.mjs} +2 -2
- package/dist/{platform-lifecycle-3uI-E2bF.mjs → platform-lifecycle-B6LUBwjS.mjs} +1 -1
- package/dist/{platform-lifecycle-CXmXe2xt.mjs → platform-lifecycle-D2RS7DE0.mjs} +236 -26
- package/dist/{platform-management-PdrgDQTe.mjs → platform-management-C-T0ch4y.mjs} +1 -1
- package/dist/{platform-management-BBCHfwji.mjs → platform-management-d3ETv3Dw.mjs} +14 -14
- package/dist/{platform-plans-config-BGwkXYDM.mjs → platform-plans-config-B7yJQKf7.mjs} +114 -30
- package/dist/{platform-recovery-C8NxXGRR.mjs → platform-recovery-DS5CAsly.mjs} +2 -2
- package/dist/{plugin-inference-CErfTgEx.mjs → plugin-inference-DZHmVe1f.mjs} +3 -3
- package/dist/{prepare-BDKWZgfL.mjs → prepare-AVM4Hj3T.mjs} +8 -8
- package/dist/prepare-BSXKz6m8.mjs +1 -0
- package/dist/{prepare-BLrzXjIl.mjs → prepare-DMk8NAO-.mjs} +1 -1
- package/dist/{project-cmd-DzGvxXKH.mjs → project-cmd-TQKAOTMV.mjs} +15 -15
- package/dist/{project-paths-G0yut6Zz.mjs → project-paths-CUhCPMpK.mjs} +33 -2
- package/dist/{project-team-C5XtHbZk.mjs → project-team-B1OKeb-T.mjs} +1 -1
- package/dist/{project-token-B4D5yhHQ.mjs → project-token-RW_wpmN-.mjs} +1 -1
- package/dist/{project-tsconfig-nhnTWO_Y.mjs → project-tsconfig-MyRJgufB.mjs} +1 -1
- package/dist/{project-zero-trust--0LvktDg.mjs → project-zero-trust-TNc66p0_.mjs} +1 -1
- package/dist/{protocol-B1Tvc9-x.mjs → protocol-IPSWHolJ.mjs} +54 -19
- package/dist/{protocol-Cg2I81NA.d.mts → protocol-YS3tbxWE.d.mts} +2 -2
- package/dist/{provision-CAcrauvr.mjs → provision-BLdkpFT4.mjs} +1 -1
- package/dist/{provision-C3yiHdld.mjs → provision-bgQTi5QZ.mjs} +2 -2
- package/dist/redirect-Dqb4fEc5.mjs +80 -0
- package/dist/{requests-CrRiTgQA.mjs → requests-Cj15-yrI.mjs} +1 -1
- package/dist/{rollback-BsmQyj-Q.mjs → rollback-CYnkng7B.mjs} +2 -2
- package/dist/{route-types-CgtlFCDz.mjs → route-types-C6eAOmOj.mjs} +1 -1
- package/dist/runtime/auth.d.mts +1 -1
- package/dist/runtime/auth.mjs +1 -1
- package/dist/runtime/better-auth-mysql.d.mts +1 -1
- package/dist/runtime/better-auth-mysql.mjs +1 -1
- package/dist/runtime/better-auth-pg.d.mts +1 -1
- package/dist/runtime/better-auth-pg.mjs +1 -1
- package/dist/runtime/better-auth.d.mts +1 -1
- package/dist/runtime/better-auth.mjs +1 -1
- package/dist/runtime/client-react.d.mts +1 -1
- package/dist/runtime/client-solid.d.mts +1 -1
- package/dist/runtime/client-svelte.d.mts +1 -1
- package/dist/runtime/client-vue.d.mts +1 -1
- package/dist/runtime/client.d.mts +1 -1
- package/dist/runtime/handler.d.mts +1 -1
- package/dist/runtime/live-client.d.mts +1 -1
- package/dist/runtime/live-server.mjs +1 -1
- package/dist/runtime/live.d.mts +1 -1
- package/dist/runtime/live.mjs +1 -1
- package/dist/runtime/routing.d.mts +2 -2
- package/dist/runtime/routing.mjs +6 -5
- package/dist/runtime/validator.d.mts +1 -1
- package/dist/runtime/ws-server.d.mts +3 -3
- package/dist/runtime/ws-server.mjs +1 -1
- package/dist/runtime/ws.d.mts +1 -1
- package/dist/{scan-BJ3bj6aP.mjs → scan-4YOxDaw2.mjs} +2 -2
- package/dist/{secret-D0g5oBsP.mjs → secret-BSf7dgg_.mjs} +3 -3
- package/dist/{action-key-ByZ6DDld.mjs → url-DaehRGKR.mjs} +43 -1
- package/dist/{version-metadata-eUd6Ar_U.mjs → version-metadata-CeftH0fQ.mjs} +1 -1
- package/dist/{wrangler-k40T7XTQ.mjs → wrangler-B1gkT_wC.mjs} +3 -3
- package/dist/wrangler-fNGvPTlO.mjs +1 -0
- package/dist/{wrapper-CVMZarxf.mjs → wrapper-xJ4LP5A7.mjs} +3 -3
- package/dist/{ws--U7QicYy.d.mts → ws-C2zy0QBf.d.mts} +2 -2
- package/docs/guide/ai.md +1 -1
- package/docs/guide/app-types.md +1 -1
- package/docs/guide/auth.md +22 -27
- package/docs/guide/database/d1.md +4 -2
- package/docs/guide/database.md +29 -27
- package/docs/guide/deployment.md +2 -2
- package/docs/guide/edge/headers.md +3 -3
- package/docs/guide/edge/prerendering.md +5 -5
- package/docs/guide/edge/redirects.md +1 -1
- package/docs/guide/edge/revalidation.md +4 -2
- package/docs/guide/edge/rewrites.md +1 -1
- package/docs/guide/edge/static-assets.md +4 -0
- package/docs/guide/email/sending.md +4 -2
- package/docs/guide/live.md +1 -1
- package/docs/guide/pages-routing/actions-and-forms.md +25 -7
- package/docs/guide/pages-routing/errors.md +17 -9
- package/docs/guide/pages-routing/head.md +44 -1
- package/docs/guide/pages-routing/islands.md +3 -1
- package/docs/guide/pages-routing/layouts.md +2 -2
- package/docs/guide/pages-routing/loaders.md +3 -1
- package/docs/guide/pages-routing/markdown.md +5 -3
- package/docs/guide/pages-routing/overview.md +14 -21
- package/docs/guide/platform/administration/connected-apps.md +10 -3
- package/docs/guide/platform/administration/email.md +1 -1
- package/docs/guide/platform/administration/plans.md +34 -1
- package/docs/guide/platform/administration/projects.md +6 -2
- package/docs/guide/platform/installation/credentials.md +12 -10
- package/docs/guide/platform/installation/maintenance.md +7 -1
- package/docs/guide/platform/installation/setup.md +8 -7
- package/docs/guide/queues.md +1 -1
- package/docs/guide/server-routing.md +2 -2
- package/docs/guide/sse.md +1 -1
- package/docs/guide/ssg.md +17 -6
- package/docs/guide/storage.md +1 -1
- package/docs/guide/testing.md +9 -7
- package/docs/guide/type-safety.md +23 -21
- package/docs/integrations/cloudflare.md +6 -2
- package/docs/integrations/frameworks/nuxt.md +1 -1
- package/docs/integrations/hono.md +21 -0
- package/docs/integrations/nodejs-bun-deno.md +4 -4
- package/docs/reference/api/auth.md +22 -4
- package/docs/reference/api/database.md +2 -2
- package/docs/reference/api/pages.md +17 -13
- package/docs/reference/api/resources.md +1 -1
- package/docs/reference/api/rewrites.md +8 -4
- package/docs/reference/api.md +1 -1
- package/docs/reference/cli/deploy.md +4 -2
- package/docs/reference/cli/platform-config.md +3 -3
- package/docs/reference/cli/platform-users.md +58 -11
- package/docs/reference/cli.md +1 -1
- package/docs/reference/config.md +7 -3
- package/package.json +7 -7
- package/skills/void/SKILL.md +1 -1
- package/dist/client-D1Vz1Zep.mjs +0 -1
- package/dist/deploy-DMieisRu.mjs +0 -2
- package/dist/discover-1DJD4YXD.mjs +0 -1
- package/dist/gen-M5fNQKfH.mjs +0 -1
- package/dist/help-CItQVDL4.mjs +0 -1
- package/dist/load-user-env-CSwdofj0.mjs +0 -48
- package/dist/login-ZHsAm-I6.mjs +0 -1
- package/dist/migrate-BflbbZQK.mjs +0 -1
- package/dist/operator-cmd-D6qNuJ_z.mjs +0 -1
- package/dist/platform-args-DJvF1-kl.mjs +0 -1
- package/dist/prepare-a1_5usAn.mjs +0 -1
- package/dist/url-CuoEn0o3.mjs +0 -43
- package/dist/wrangler-R3kMdJfw.mjs +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as join, l as toSlash, n as dirname, r as extname } from "./dist-DMYe8CZJ.mjs";
|
|
2
|
-
import { l as getDatabaseDialect, p as readConfig } from "./config-
|
|
3
|
-
import { c as voidDbBundlerPlugin, r as cloudflareQueueName, t as generateQueueResolverSource } from "./dispatch-
|
|
4
|
-
import { n as readProjectPaths } from "./project-paths-
|
|
2
|
+
import { l as getDatabaseDialect, p as readConfig } from "./config-CzFdJYNA.mjs";
|
|
3
|
+
import { c as voidDbBundlerPlugin, r as cloudflareQueueName, t as generateQueueResolverSource } from "./dispatch-BBfb519j.mjs";
|
|
4
|
+
import { n as readProjectPaths } from "./project-paths-CUhCPMpK.mjs";
|
|
5
5
|
import { t as WORKER_CONDITIONS } from "./worker-conditions-CBZ0RYsZ.mjs";
|
|
6
6
|
import { t as MagicString } from "./dist-B6eN80gc.mjs";
|
|
7
7
|
import { n as isIdentifier, r as isLiteral } from "./ast-Cv0JwXqb.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as StandardSchemaV1 } from "./standard-schema-CuDawHOC.mjs";
|
|
2
|
-
import { i as AuthUser } from "./auth-
|
|
3
|
-
import { a as CloudEnv } from "./handler-
|
|
2
|
+
import { i as AuthUser } from "./auth-CV9kXHKe.mjs";
|
|
3
|
+
import { a as CloudEnv } from "./handler-6fzr_ikp.mjs";
|
|
4
4
|
import { WebSocketRouteMap } from "void/routes";
|
|
5
5
|
type MaybePromise<T> = T | Promise<T>;
|
|
6
6
|
type ParamsRecord = Record<string, string>;
|
package/docs/guide/ai.md
CHANGED
|
@@ -142,7 +142,7 @@ const result = await ai.run('google/gemini-2.5-flash', {
|
|
|
142
142
|
});
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
-
Pass AI Gateway options as the third argument: `ai.run(model, inputs, { gateway: { skipCache: true } })`. On a team platform, the platform chooses the gateway and sets its metadata and logging; options such as `skipCache` and `cacheTtl` still apply.
|
|
145
|
+
Pass AI Gateway options as the third argument: `ai.run(model, inputs, { gateway: { skipCache: true } })`. On a team platform, the platform chooses the gateway and sets its metadata and logging; options such as `skipCache` and `cacheTtl` still apply. The platform's logging setting also covers `void dev` in a linked project; an unlinked project uses your own Cloudflare account and its gateway settings.
|
|
146
146
|
|
|
147
147
|
For provider-native requests on a direct deployment, configure [`ai.gateway`](../integrations/cloudflare.md#ai-self-host).
|
|
148
148
|
|
package/docs/guide/app-types.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: 'Build a Void app,
|
|
2
|
+
description: 'Build a Void app, use your existing Vite framework, or deploy a static site. Void manages resources and deployment for each.'
|
|
3
3
|
outline: deep
|
|
4
4
|
---
|
|
5
5
|
|
package/docs/guide/auth.md
CHANGED
|
@@ -38,9 +38,9 @@ await auth.signIn.email({
|
|
|
38
38
|
});
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
### 3. Protect a server route
|
|
41
|
+
### 3. Protect a server route {#protect-a-server-route}
|
|
42
42
|
|
|
43
|
-
Call `requireAuth` in a route handler or
|
|
43
|
+
Call `requireAuth` in a route handler or action to get the signed-in user or reject unauthenticated requests with `401`:
|
|
44
44
|
|
|
45
45
|
```ts
|
|
46
46
|
// routes/api/profile.ts
|
|
@@ -53,21 +53,29 @@ export const GET = defineHandler((c) => {
|
|
|
53
53
|
});
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
In a
|
|
56
|
+
In a page loader, pass `throwRedirect` to send unauthenticated visitors to your login page instead of a plain-text `401`:
|
|
57
57
|
|
|
58
58
|
```ts
|
|
59
59
|
// pages/dashboard.server.ts
|
|
60
60
|
import { defineHandler, type InferProps } from 'void';
|
|
61
|
-
import {
|
|
61
|
+
import { requireAuth } from 'void/auth';
|
|
62
62
|
|
|
63
63
|
export type Props = InferProps<typeof loader>;
|
|
64
64
|
|
|
65
|
-
export const loader = defineHandler(() => {
|
|
66
|
-
const user =
|
|
65
|
+
export const loader = defineHandler((c) => {
|
|
66
|
+
const user = requireAuth(c, {
|
|
67
|
+
throwRedirect: '/login',
|
|
68
|
+
});
|
|
67
69
|
return { user };
|
|
68
70
|
});
|
|
69
71
|
```
|
|
70
72
|
|
|
73
|
+
The same option works in actions and middleware. It throws a redirect, stopping execution: `302` for GET/HEAD requests and `303` for other methods. Document requests follow the redirect normally; Pages client navigation follows it without reloading the document.
|
|
74
|
+
|
|
75
|
+
Signing in does not replay a rejected action.
|
|
76
|
+
|
|
77
|
+
To allow unauthenticated access, use `getUser()` and return the nullable user. For custom guards, you can also [throw a redirect](../integrations/hono.md#redirects) from a helper.
|
|
78
|
+
|
|
71
79
|
### 4. Sign out
|
|
72
80
|
|
|
73
81
|
```tsx
|
|
@@ -119,25 +127,16 @@ import { getSession, getUser, requireAuth } from 'void/auth';
|
|
|
119
127
|
- `getUser()` returns the current `AuthUser | null`
|
|
120
128
|
- `getSession()` returns `{ user, session } | null`
|
|
121
129
|
- `requireAuth(c)` returns the authenticated user or throws `401`
|
|
130
|
+
- `requireAuth(c, { throwRedirect: '/login' })` returns the user or throws a login redirect
|
|
122
131
|
- [`getAuth(c)`](../reference/api/auth.md#getauth-c) returns the request's Better Auth instance, with plugin APIs inferred from `auth.ts`, for use with Better Auth helpers.
|
|
123
132
|
|
|
124
133
|
Import `AuthUser` and `AuthSession` from `void/auth` for type annotations. They include the fields your Better Auth plugins and `user.additionalFields` add, such as `role` from `admin()`. See their fields in the [API reference](../reference/api/auth.md#authuser).
|
|
125
134
|
|
|
126
135
|
## Querying Authentication Tables
|
|
127
136
|
|
|
128
|
-
|
|
129
|
-
The generated file exports the core authentication tables:
|
|
130
|
-
|
|
131
|
-
- `userTable`
|
|
132
|
-
- `sessionTable`
|
|
133
|
-
- `accountTable`
|
|
134
|
-
- `verificationTable`
|
|
137
|
+
To query users or reference them from your own tables, import Void's generated authentication schema. It exports `userTable`, `sessionTable`, `accountTable`, `verificationTable`, and any tables added by your Better Auth plugins.
|
|
135
138
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
The generated file path and core table export names are documented integration points. You can import these exports directly rather than recreating the tables in your application.
|
|
139
|
-
|
|
140
|
-
To import these tables into your application, add a TypeScript path alias to your root `tsconfig.json`:
|
|
139
|
+
Add an alias to your root `tsconfig.json`:
|
|
141
140
|
|
|
142
141
|
```json
|
|
143
142
|
{
|
|
@@ -149,11 +148,9 @@ To import these tables into your application, add a TypeScript path alias to you
|
|
|
149
148
|
}
|
|
150
149
|
```
|
|
151
150
|
|
|
152
|
-
|
|
151
|
+
Keep your other path aliases, including any you use from `.void/tsconfig.json`, such as `@schema`.
|
|
153
152
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
You can now import and query authentication tables:
|
|
153
|
+
You can now query users with Drizzle:
|
|
157
154
|
|
|
158
155
|
```ts
|
|
159
156
|
import { userTable } from '@auth-schema';
|
|
@@ -164,7 +161,7 @@ export function listUsers() {
|
|
|
164
161
|
}
|
|
165
162
|
```
|
|
166
163
|
|
|
167
|
-
|
|
164
|
+
To associate a post with its author, reference `userTable.id`:
|
|
168
165
|
|
|
169
166
|
```ts
|
|
170
167
|
import { userTable } from '@auth-schema';
|
|
@@ -178,11 +175,9 @@ export const postTable = sqliteTable('post', {
|
|
|
178
175
|
});
|
|
179
176
|
```
|
|
180
177
|
|
|
181
|
-
This example
|
|
182
|
-
|
|
183
|
-
The example above uses SQLite/D1. For PostgreSQL and MySQL, use the corresponding schema modules: `void/schema-pg` and `void/schema-mysql`.
|
|
178
|
+
This example uses D1 and the default text IDs. For PostgreSQL or MySQL, use `void/schema-pg` or `void/schema-mysql`. With `advanced.database.generateId: 'serial'`, use an integer foreign key.
|
|
184
179
|
|
|
185
|
-
|
|
180
|
+
Void regenerates `.void/better-auth-schema.ts`. Configure authentication in `auth.ts` rather than editing the generated file.
|
|
186
181
|
|
|
187
182
|
## Behavior
|
|
188
183
|
|
|
@@ -43,7 +43,7 @@ await db.batch([
|
|
|
43
43
|
|
|
44
44
|
Void enables [D1 read replication](https://developers.cloudflare.com/d1/best-practices/read-replication/) when it provisions a database. To enable it on an existing database, run `void deploy --platform cloudflare --provision`. Queries through `db` from `void/db` use a D1 session for each Void request, so reads can run near the request and later queries in that request see at least the same data. Framework handlers without Void's request scope start each database operation on the primary. `createDb` starts a replica-capable session for the binding you pass it.
|
|
45
45
|
|
|
46
|
-
Replicas can lag between requests. Authentication
|
|
46
|
+
Replicas can lag between requests. Authentication checks use the primary so a lagging replica can't accept a revoked session. For other reads that need the latest primary data, create a client inside the request:
|
|
47
47
|
|
|
48
48
|
```ts
|
|
49
49
|
import { users } from '@schema';
|
|
@@ -57,7 +57,9 @@ export const GET = defineHandler(async () => {
|
|
|
57
57
|
});
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
With `session: 'first-primary'`, the first query reads from the primary and later queries see at least the same data. The default, `'first-unconstrained'`, allows the first query to use a replica.
|
|
61
|
+
|
|
62
|
+
For raw D1 calls or another query library, use `withSession()` to read from replicas. A bare D1 binding reads from the primary.
|
|
61
63
|
|
|
62
64
|
## Alternative Query Layers
|
|
63
65
|
|
package/docs/guide/database.md
CHANGED
|
@@ -388,36 +388,38 @@ See the [CLI reference](../reference/cli/database.md#database) for connection se
|
|
|
388
388
|
|
|
389
389
|
## Adopt an existing Drizzle PostgreSQL database {#adopt-existing-drizzle}
|
|
390
390
|
|
|
391
|
-
|
|
391
|
+
To use Void with a PostgreSQL database that Drizzle has already migrated, record its applied migrations before your first deployment:
|
|
392
392
|
|
|
393
393
|
1. Back up the database and pause deployments. Try the procedure on a restored copy first.
|
|
394
394
|
2. Set `database: 'pg'` in `void.config.ts`. Keep your existing schema, SQL filenames, and `db/migrations/meta/` directory. Do not regenerate or rename migrations during adoption.
|
|
395
|
-
3.
|
|
396
|
-
|
|
397
|
-
```sql
|
|
398
|
-
SELECT hash, created_at FROM drizzle.__drizzle_migrations ORDER BY created_at;
|
|
399
|
-
```
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
395
|
+
3. Read Drizzle's migration history. The default table is `drizzle.__drizzle_migrations`; use your configured schema and table if different.
|
|
396
|
+
|
|
397
|
+
```sql
|
|
398
|
+
SELECT hash, created_at FROM drizzle.__drizzle_migrations ORDER BY created_at;
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
Match each row's `created_at` to `when` in `meta/_journal.json`, and its `hash` to the SQL file's SHA-256. Resolve any differences before continuing.
|
|
402
|
+
|
|
403
|
+
4. Save this as `adopt-void.sql`. Replace the example filenames with **only the migrations you verified as applied**, including `.sql`. Leave pending migrations out.
|
|
404
|
+
|
|
405
|
+
```sql [adopt-void.sql]
|
|
406
|
+
BEGIN;
|
|
407
|
+
CREATE TABLE IF NOT EXISTS _void_migrations (
|
|
408
|
+
name TEXT PRIMARY KEY,
|
|
409
|
+
applied_at TEXT NOT NULL
|
|
410
|
+
);
|
|
411
|
+
INSERT INTO _void_migrations (name, applied_at)
|
|
412
|
+
VALUES
|
|
413
|
+
('0000_create_users.sql', CURRENT_TIMESTAMP::text),
|
|
414
|
+
('0001_add_email.sql', CURRENT_TIMESTAMP::text)
|
|
415
|
+
ON CONFLICT (name) DO NOTHING;
|
|
416
|
+
COMMIT;
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
5. Run the file with your PostgreSQL client, stopping on errors. Use the database and search path Void will use. This records the filenames without running their SQL or changing Drizzle's history.
|
|
420
|
+
6. Connect Void to the database and run `void db status`. Only new migrations should be pending. For direct Cloudflare deployments, set `DATABASE_URL` in the shell or CI environment that runs `void deploy`.
|
|
421
|
+
|
|
422
|
+
Repeat these steps for each database; development and production may have different migration histories. Keep Drizzle's history table, and use Void for future migrations.
|
|
421
423
|
|
|
422
424
|
## Hand-written migrations {#hand-written-migrations}
|
|
423
425
|
|
package/docs/guide/deployment.md
CHANGED
|
@@ -36,13 +36,13 @@ void db generate
|
|
|
36
36
|
|
|
37
37
|
Review and commit the SQL, then deploy again. Rollback does not reverse database migrations. See [Database](./database.md) for the local workflow.
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
If you run migrations in a separate release step, or a preview shares your database, deploy without applying SQL migrations:
|
|
40
40
|
|
|
41
41
|
```sh
|
|
42
42
|
void deploy --skip-migrations
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
The app must work with the database's current schema. Both deployment destinations support this option, and the next deploy without it applies pending migrations. See [`--skip-migrations`](../reference/cli/deploy.md#void-deploy) for requirements and [`void db migrate`](../reference/cli/database.md#void-db-migrate) to apply migrations separately.
|
|
46
46
|
|
|
47
47
|
For D1 on your own Cloudflare account, deploy saves a restore point before applying migrations and prints a [`void db restore`](../reference/cli/database.md#void-db-restore) command. Use it to recover from a bad migration, then fix the migration before deploying again. A restore discards writes made after that point; check that your deployed code works with the restored schema. See the command reference for the recovery steps and retention limits.
|
|
48
48
|
|
|
@@ -25,8 +25,8 @@ Define custom response headers in [`void.config.ts`](../../reference/config) usi
|
|
|
25
25
|
- **Header values** use `Name: value` format. The value may contain colons.
|
|
26
26
|
- All matching rules are merged. When multiple rules set the same header name, the **last match wins**.
|
|
27
27
|
- User-defined `Cache-Control` overrides the built-in default. The default still applies when no rule matches.
|
|
28
|
-
- With [authentication](../auth.md), responses to requests
|
|
29
|
-
- Rules apply to
|
|
28
|
+
- With [authentication](../auth.md), responses to requests with cookies or credentials stay private, and auth endpoints stay uncached, in development, on direct Cloudflare deployments, and on [other runtimes](../deployment.md#other-runtimes). On a [Void platform](../deployment.md#deploy-to-a-team-platform), header rules can replace those cache settings. Keep public cache rules away from signed-in pages and `/api/auth/*`.
|
|
29
|
+
- Rules also apply to errors, including 404s. Use immutable caching only for URLs that change with their content, so a missing file isn't cached under a permanent URL.
|
|
30
30
|
|
|
31
31
|
## Scope
|
|
32
32
|
|
|
@@ -48,4 +48,4 @@ During local development, with `void deploy --platform cloudflare`, and on [othe
|
|
|
48
48
|
|
|
49
49
|
On a Void platform, Void reads `_headers` files produced by supported frameworks. Your `routing.headers` rules run afterward, so they can override framework defaults.
|
|
50
50
|
|
|
51
|
-
For
|
|
51
|
+
For direct Cloudflare framework deployments, put `_headers` in your framework's public asset directory. Its rules apply to static files, including when a deployment preserves existing secrets. To set headers on Worker responses, use your framework's server code.
|
|
@@ -23,7 +23,7 @@ Pages without dynamic params do not need `getPrerenderPaths()`.
|
|
|
23
23
|
|
|
24
24
|
## Dynamic pages (with params)
|
|
25
25
|
|
|
26
|
-
For
|
|
26
|
+
For a dynamic page, export `getPrerenderPaths()` to choose which paths to render. Annotate its return type with [`PageParams`](../../reference/api/types.md#route-types) so TypeScript checks the parameter names:
|
|
27
27
|
|
|
28
28
|
```ts
|
|
29
29
|
// pages/blog/[slug].server.ts
|
|
@@ -31,12 +31,14 @@ import type { PageParams } from 'void/routes';
|
|
|
31
31
|
|
|
32
32
|
export const prerender = true;
|
|
33
33
|
|
|
34
|
-
export async function getPrerenderPaths(): Promise<PageParams<'/blog
|
|
34
|
+
export async function getPrerenderPaths(): Promise<PageParams<'/blog/[slug]'>[]> {
|
|
35
35
|
return [{ slug: 'hello-world' }, { slug: 'getting-started' }];
|
|
36
36
|
}
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
Return an object for each path, with every required parameter. Values can be strings or numbers; Void URL-encodes them. Use a catch-all page such as `pages/docs/[...slug]` for values containing `/`, for example `{ slug: 'guides/intro' }`.
|
|
40
|
+
|
|
41
|
+
The type annotation is required for TypeScript to check the keys. At deployment, Void reports invalid entries with their server filename and index.
|
|
40
42
|
|
|
41
43
|
## Custom SSR
|
|
42
44
|
|
|
@@ -51,8 +53,6 @@ export async function getPrerenderPaths(): Promise<string[]> {
|
|
|
51
53
|
}
|
|
52
54
|
```
|
|
53
55
|
|
|
54
|
-
Annotate this return type as an array of path strings. Use `PageParams` on file-based pages, where the function returns param objects.
|
|
55
|
-
|
|
56
56
|
## Relationship to revalidation
|
|
57
57
|
|
|
58
58
|
Setting `routing.isr: false` in `void.config.ts` disables ISR and this edge-prerendering behavior, including per-page exports. It does not disable build-time HTML generation with `output: "static"`.
|
|
@@ -24,7 +24,7 @@ Define URL redirects in [`void.config.ts`](../../reference/config) using the `ro
|
|
|
24
24
|
- **Destinations** can be strings (default `302`) or objects with `to` and optional `status`. Supported statuses: `301`, `302`, `303`, `307`, `308`.
|
|
25
25
|
- `:splat` in the destination is replaced with the portion of the path matched by `*` in the source pattern.
|
|
26
26
|
- Destination query strings are merged into the `Location` header (the destination's parameters take precedence on per-key conflict). To drop the incoming query, write an explicit reset like `?`.
|
|
27
|
-
-
|
|
27
|
+
- For redirects from a handler, loader, or middleware, use [`c.redirect()`](../../reference/api/rewrites.md#c-rewrite-destination). It sends the location you provide without adding the request query. Named actions keep their own query parameters and drop the action key when redirecting to GET.
|
|
28
28
|
- When multiple rules match, the **first match wins**. Put specific patterns before catch-all patterns.
|
|
29
29
|
- Redirects are evaluated **before** the request reaches the worker, so they short-circuit static asset serving, ISR, and SSR.
|
|
30
30
|
|
|
@@ -62,7 +62,7 @@ export const loader = defineHandler(async (c) => {
|
|
|
62
62
|
});
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
Use a whole
|
|
65
|
+
Use a whole number such as `3600` directly in the export. Expressions such as `60 * 60` and re-exports are ignored with a warning.
|
|
66
66
|
|
|
67
67
|
Per-page values take precedence over `void.config.ts` patterns.
|
|
68
68
|
|
|
@@ -109,6 +109,8 @@ Responses that vary by request headers, such as `Vary: Accept-Language` or `Vary
|
|
|
109
109
|
|
|
110
110
|
Requests with `Cookie`, `Authorization`, or Cloudflare Access's `Cf-Access-Jwt-Assertion` header bypass the ISR cache entirely and always dispatch to the worker. Authenticated responses are not shared between users, including when Access authentication supplies no cookie.
|
|
111
111
|
|
|
112
|
+
A request that negotiates a representation other than the cached HTML document also bypasses the cache, because each path holds a single cached body. That covers `Accept: text/event-stream` and `Accept: text/markdown`, so middleware that answers those requests in another format runs on every request.
|
|
113
|
+
|
|
112
114
|
## Cache keys and rewrites
|
|
113
115
|
|
|
114
116
|
For a dispatch rewrite, the cache key includes both the destination and original pathname. A direct request to `/en/docs/foo` therefore uses a different entry from `/docs/foo` rewritten to that destination.
|
|
@@ -138,4 +140,4 @@ export const POST = defineHandler(async (c) => {
|
|
|
138
140
|
});
|
|
139
141
|
```
|
|
140
142
|
|
|
141
|
-
With [`routing.typedRoutes`](../../reference/config.md#routing-typedroutes)
|
|
143
|
+
With [`routing.typedRoutes`](../../reference/config.md#routing-typedroutes), TypeScript checks each path against your routes. For a path you validate at runtime, use `as RouteUrl` from `void/routes` to skip the type check.
|
|
@@ -57,7 +57,7 @@ Keep access checks on any destination that needs them.
|
|
|
57
57
|
|
|
58
58
|
A destination without `?` preserves the incoming query string. `c.rewrite('/search')` keeps `?q=...`, while `c.rewrite('/search?q=all')` replaces it.
|
|
59
59
|
|
|
60
|
-
Your editor suggests known routes through
|
|
60
|
+
Your editor suggests known routes through [`RewriteDestination`](../../reference/api/rewrites.md#rewritedestination). Enable [`routing.typedRoutes`](../../reference/config.md#routing-typedroutes) to reject strings that don't match a route. For a path you build at runtime, import `RouteUrl` from `void/routes` and use a cast, such as ``c.rewrite(`/en${c.req.path}` as RouteUrl)``.
|
|
61
61
|
|
|
62
62
|
### Runtime rewrites cannot reach static assets
|
|
63
63
|
|
|
@@ -91,6 +91,10 @@ Choose `single-page-application`, `404-page`, or `none`. These settings preserve
|
|
|
91
91
|
|
|
92
92
|
SvelteKit, Nuxt, Analog, and Astro handle their own error pages and ignore `routing.notFound`. For direct Cloudflare deployment with TanStack Start, React Router, or vinext, configure the asset binding, directory, and routing policy through the framework's Cloudflare config.
|
|
93
93
|
|
|
94
|
+
On direct Cloudflare deployments, SvelteKit, Nuxt, Analog, and Astro serve built files and prerendered pages without running the Worker. Other requests reach the framework.
|
|
95
|
+
|
|
96
|
+
To run server code before serving an asset, set [`run_worker_first`](https://developers.cloudflare.com/workers/static-assets/binding/#run_worker_first) under `cloudflare.assets` in `void.config.ts`. Setting it to `true` runs the Worker on every request and counts toward Worker request usage.
|
|
97
|
+
|
|
94
98
|
## API routes and SSR pages
|
|
95
99
|
|
|
96
100
|
API responses and SSR pages are not cached as static assets. Use [Revalidation](./revalidation) to cache public rendered pages.
|
|
@@ -92,7 +92,7 @@ On your own Cloudflare account, `from` defaults to `email.from` from `void.confi
|
|
|
92
92
|
|
|
93
93
|
## Reply later {#reply-later}
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
To reply from a queue job or another later task, save the incoming message's thread IDs and pass them to `sendEmail`:
|
|
96
96
|
|
|
97
97
|
```ts
|
|
98
98
|
// email/support.ts
|
|
@@ -117,7 +117,9 @@ await sendEmail({
|
|
|
117
117
|
});
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
Mail clients use `threading` to show the reply in the same conversation. Set `inReplyTo` to the parent's `Message-ID`. For a longer thread, set `references` to the earlier IDs in order, ending with the parent; otherwise it defaults to `inReplyTo`.
|
|
121
|
+
|
|
122
|
+
Use `threading` rather than custom `In-Reply-To` or `References` headers. Invalid thread IDs are omitted without stopping the send. For an immediate reply inside the inbound handler, use [`replyEmail()`](./receiving.md#threaded-replies).
|
|
121
123
|
|
|
122
124
|
## Attachments {#attachments}
|
|
123
125
|
|
package/docs/guide/live.md
CHANGED
|
@@ -78,7 +78,7 @@ stream.close();
|
|
|
78
78
|
|
|
79
79
|
Subscription IDs are scoped to a connection. Reusing an ID replaces its subscription. After reconnecting, the helper restores active subscriptions and sends their latest `eventId` as `lastEventId`.
|
|
80
80
|
|
|
81
|
-
With [`routing.typedRoutes`](../reference/config.md#routing-typedroutes), the URL
|
|
81
|
+
With [`routing.typedRoutes`](../reference/config.md#routing-typedroutes), TypeScript checks the URL against your routes. External `http://` and `https://` URLs also work. For a URL you validate at runtime, use `as RouteUrl` from `void/routes` to skip the type check.
|
|
82
82
|
|
|
83
83
|
## Publish
|
|
84
84
|
|
|
@@ -200,13 +200,25 @@ const form = useForm(
|
|
|
200
200
|
|
|
201
201
|
`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.
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
When awaiting `router.visit()` or `router.refresh()` inside a callback, pass `{ resolveOn: 'data' }`. The callback can then finish before React commits the navigation. See [React navigation completion](../../reference/api/pages.md#react-navigation-completion).
|
|
204
204
|
|
|
205
205
|
Vue, Svelte, and Solid submissions return a promise instead; use `await form.post()` to run work after a submission.
|
|
206
206
|
|
|
207
207
|
### Query parameters after submission
|
|
208
208
|
|
|
209
|
-
|
|
209
|
+
Actions and forms keep the current page's query parameters when submitting to that page. For example, from `/items?page=2&search=foo`:
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
import { action } from '@void/react'; // or "@void/vue", "@void/svelte", "@void/solid"
|
|
213
|
+
|
|
214
|
+
// The action and loader receive page=2 and search=foo.
|
|
215
|
+
await action('/items?vote');
|
|
216
|
+
|
|
217
|
+
// An explicit parameter overrides the current page's value.
|
|
218
|
+
await action('/items?vote&page=1');
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
The page URL, scroll position, and history entry stay unchanged.
|
|
210
222
|
|
|
211
223
|
A redirect from the action does not receive the page's query parameters. To clear them after an action, return `c.redirect('/items')`.
|
|
212
224
|
|
|
@@ -301,7 +313,9 @@ if (!result.ok) {
|
|
|
301
313
|
|
|
302
314
|
`action()` defaults to `POST`. Pass `data`, `params`, and `method` to set the body, route parameters, or HTTP method.
|
|
303
315
|
|
|
304
|
-
A successful call returns `{ ok: true, pageData }`. Expected errors, such as validation failures or conflicts, return `{ ok: false, error }`.
|
|
316
|
+
A successful call returns `{ ok: true, pageData }`. Expected errors, such as validation failures or conflicts, return `{ ok: false, error }`.
|
|
317
|
+
|
|
318
|
+
For `4xx` errors, `error.message` uses the [`HTTPException`](../../integrations/hono.md#utilities) message or the body of a plain-text response. Other response formats use a status summary, such as `Action failed with 404 Not Found`.
|
|
305
319
|
|
|
306
320
|
## Validation Errors
|
|
307
321
|
|
|
@@ -311,7 +325,7 @@ Expected errors such as `400`, `404`, `409`, `422`, and `429` stay with the form
|
|
|
311
325
|
|
|
312
326
|
By default, authentication errors (`401`, `403`) and server errors (`500`, `502`) are thrown. Handle them with your framework's error boundary or error handling.
|
|
313
327
|
|
|
314
|
-
To
|
|
328
|
+
To keep the form visible when a request fails, pass `throwOnError: false`:
|
|
315
329
|
|
|
316
330
|
```ts
|
|
317
331
|
import { useForm } from '@void/react'; // or "@void/vue", "@void/svelte", "@void/solid"
|
|
@@ -319,9 +333,11 @@ import { useForm } from '@void/react'; // or "@void/vue", "@void/svelte", "@void
|
|
|
319
333
|
const form = useForm('/users', { name: '', email: '' }, { throwOnError: false });
|
|
320
334
|
```
|
|
321
335
|
|
|
322
|
-
|
|
336
|
+
Validation errors appear in `form.errors`; other HTTP failures appear in `form.error`. `Form` displays the error for you. In React, `onError` also receives it.
|
|
323
337
|
|
|
324
|
-
|
|
338
|
+
Network errors and other unexpected failures still throw. Cancelled submissions don't set a form error.
|
|
339
|
+
|
|
340
|
+
Use `isVoidActionError()` to read an action error's `status` and `message`, including thrown errors:
|
|
325
341
|
|
|
326
342
|
```ts
|
|
327
343
|
import { isVoidActionError } from '@void/react'; // or "@void/vue", "@void/svelte", "@void/solid"
|
|
@@ -335,6 +351,8 @@ function describeError(error: unknown) {
|
|
|
335
351
|
}
|
|
336
352
|
```
|
|
337
353
|
|
|
354
|
+
Use `isCallSiteActionError()` to recognize only the expected errors returned by `action()`.
|
|
355
|
+
|
|
338
356
|
Actions can throw `ValidationError` for custom validation logic:
|
|
339
357
|
|
|
340
358
|
```ts
|
|
@@ -461,7 +479,7 @@ export const action = defineHandler(async (c) => {
|
|
|
461
479
|
});
|
|
462
480
|
```
|
|
463
481
|
|
|
464
|
-
`withValidator({ body })` accepts
|
|
482
|
+
`withValidator({ body })` also accepts uploads. Nested field names such as `profile[name]`, `tags[0]`, and `tags[]` become objects and arrays. Coerce other values in your schema: booleans arrive as `'1'` or `'0'`, numbers and dates as strings, and `null` as `''`.
|
|
465
483
|
|
|
466
484
|
Pick the storage key on the server and allow only the file types you expect. See [Serving Files](../storage.md#serving-files) to send them back safely.
|
|
467
485
|
|
|
@@ -5,7 +5,7 @@ outline: deep
|
|
|
5
5
|
|
|
6
6
|
# Not Found & Errors
|
|
7
7
|
|
|
8
|
-
Add `_not-found` and `_error` components to `pages
|
|
8
|
+
Keep your app's navigation and layout visible when a page is missing or fails. Add `_not-found` and `_error` components to `pages/`; both receive an `error` prop with `status` and `message`:
|
|
9
9
|
|
|
10
10
|
::: code-group
|
|
11
11
|
|
|
@@ -69,7 +69,9 @@ export default function ErrorPage(props: ErrorPageProps) {
|
|
|
69
69
|
|
|
70
70
|
:::
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
## Missing pages
|
|
73
|
+
|
|
74
|
+
To show `_not-found` when a product doesn't exist, return a 404 from its loader. This works the same way in all four adapters:
|
|
73
75
|
|
|
74
76
|
```ts
|
|
75
77
|
// pages/products/[id].server.ts
|
|
@@ -78,24 +80,30 @@ import { defineHandler } from 'void/handler';
|
|
|
78
80
|
export const loader = defineHandler((c) => c.notFound());
|
|
79
81
|
```
|
|
80
82
|
|
|
81
|
-
`
|
|
83
|
+
Throwing `HTTPException(404)` also shows `_not-found`. A root `pages/_not-found` handles URLs that don't match any page or API route.
|
|
84
|
+
|
|
85
|
+
In middleware, `c.notFound()` shows the root `_not-found` without running a page loader. To send a custom response instead, return `c.text('Not Found', 404)`.
|
|
86
|
+
|
|
87
|
+
## Failed pages
|
|
88
|
+
|
|
89
|
+
`_error` handles unexpected loader and rendering failures. In production, visitors see a generic message and error details stay in your server logs. Development shows the error message.
|
|
82
90
|
|
|
83
|
-
|
|
91
|
+
Action errors that reach a client boundary keep their HTTP status and public message. Redirects, authentication responses, and API errors keep their usual behavior.
|
|
84
92
|
|
|
85
93
|
## Nested errors
|
|
86
94
|
|
|
87
|
-
Put
|
|
95
|
+
Put an error component in a subdirectory to customize that section. Void uses the closest one and keeps its surrounding layouts. If a layout fails, an error component outside that layout handles it. If an error component fails, Void tries an outer one, then its built-in error page.
|
|
88
96
|
|
|
89
97
|
Boundary components don't have `.server` companions, actions, or their own `layout` export. They aren't routes: `/error` and `/not-found` remain available for ordinary pages. `.dev` and `.prod` variants work like other Pages components.
|
|
90
98
|
|
|
91
99
|
## Recovery
|
|
92
100
|
|
|
93
|
-
|
|
101
|
+
Call `useRouter().refresh()` from an interactive error component to retry the page's loader. It fetches fresh data without repeating a form submission. A regular link or document reload also works. Error responses aren't cached by the client router.
|
|
94
102
|
|
|
95
|
-
|
|
103
|
+
Client rendering errors use your framework's error boundaries. Event handlers, detached async tasks, and independent islands keep the framework's usual error handling. For deferred data, React can throw rejected promises during rendering; Vue, Svelte, and Solid expose an error state your component can display.
|
|
96
104
|
|
|
97
105
|
## Rendering modes
|
|
98
106
|
|
|
99
|
-
`ssr = false
|
|
107
|
+
With `ssr = false`, the error component renders in the browser. Island pages render errors on the server without a client router. Error components receive the shared context of the page they replace.
|
|
100
108
|
|
|
101
|
-
With `output: 'static'`, a root `_not-found` produces `404.html` unless
|
|
109
|
+
With `output: 'static'`, a root `_not-found` produces `404.html` unless you provide one. It renders at build time with empty shared data and parameters, without request middleware or hydration. Keep it and its layouts usable without a signed-in user. Your static host sets the response status for unknown URLs.
|