void 1.6.2 → 1.7.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-D903EEWQ.mjs → account-cmd-BfkJ_1PC.mjs} +6 -6
- package/dist/{application-analysis-DlUG-XNT.mjs → application-analysis-OV0CBJ80.mjs} +8 -7
- package/dist/{application-routing-GCBSwXA9.mjs → application-routing-QpyC5G8z.mjs} +2 -1
- package/dist/{auth-CL-p_rqV.mjs → auth-BN0NU9dz.mjs} +1 -1
- package/dist/{auth-Dy8svcqQ.mjs → auth-CCk9Seol.mjs} +2 -2
- package/dist/{auth-CH4PLAX1.d.mts → auth-CZrthGxs.d.mts} +8 -1
- package/dist/{auth-YVjBX5NY.mjs → auth-DyWp-fSo.mjs} +7 -1
- package/dist/{auth-link-g9J7MSmP.mjs → auth-link-CW1Zh6FM.mjs} +6 -6
- package/dist/{auth-router-DMZbG9Qn.mjs → auth-router-CNBKnEZi.mjs} +3 -3
- package/dist/{better-auth-shared-BJyG2mH0.d.mts → better-auth-shared-C-0uZg8-.d.mts} +1 -1
- package/dist/{better-auth-shared-C958aM7W.mjs → better-auth-shared-CdVyCUou.mjs} +1 -1
- package/dist/{build-cmd-DmjbuT6d.mjs → build-cmd-C9qOKW9W.mjs} +5 -5
- package/dist/{cache-2khBO1MR.mjs → cache-DVBBbWQL.mjs} +5 -5
- package/dist/{cancel-deploy-_itbbvY3.mjs → cancel-deploy-COavnjud.mjs} +4 -4
- package/dist/{cf-build-output-B1C8U83u.mjs → cf-build-output-CWNOH-KA.mjs} +2 -1
- package/dist/cf-build-output-DUZnAeZ1.mjs +1 -0
- package/dist/{cf-config-migrate-Dy8MrKgF.mjs → cf-config-migrate-Bb-EdAQq.mjs} +5 -1
- package/dist/cli/cli.mjs +68 -1868
- package/dist/cli/cloudflare-operation-process.mjs +10 -8
- package/dist/cli/env-schema-probe.mjs +3 -3
- package/dist/cli-main-DFteHrJI.mjs +1889 -0
- package/dist/client-BAxLpSKv.mjs +1 -0
- package/dist/{client-CoxPEhJq.mjs → client-BEZmTP6p.mjs} +10 -4
- package/dist/{cloudflare-auth-CuS42-9A.mjs → cloudflare-auth-DGIivpTb.mjs} +1 -1
- package/dist/{cloudflare-cmd-DTF19-j-.mjs → cloudflare-cmd-DJaxC-bc.mjs} +5 -5
- package/dist/{cloudflare-config-Ce8j5S7V.mjs → cloudflare-config-DtOGAbeB.mjs} +2 -2
- package/dist/{cloudflare-connect-BN4dHp8i.mjs → cloudflare-connect-BjpWmglw.mjs} +3 -3
- package/dist/{cloudflare-operations-laxRA8HN.mjs → cloudflare-operations-CZkjFrzH.mjs} +1 -1
- package/dist/{cloudflare-operations-DrZGzQap.mjs → cloudflare-operations-k7wYUv56.mjs} +6 -6
- package/dist/{cloudflare-process-D9aC-jXr.mjs → cloudflare-process-BcPvlMFd.mjs} +2 -2
- package/dist/{config-hL-S-Y9D.mjs → config-5oSQhZNj.mjs} +3 -1
- package/dist/{config-CPxJmt4M.d.mts → config-CTlUaXWZ.d.mts} +3 -1
- package/dist/{config-CNDjO-15.mjs → config-DcqUBGCb.mjs} +1 -1
- package/dist/config-entry.d.mts +1 -1
- package/dist/{config-DMR0i3Z2.mjs → config-wo2EaH0X.mjs} +1 -1
- package/dist/{connect-DHepM7Xs.mjs → connect-j1F1C_rW.mjs} +7 -7
- package/dist/{create-project-Bq0M8MtO.mjs → create-project-CE3jOmd5.mjs} +5 -5
- package/dist/{create-project-BiMmR5wA.mjs → create-project-DZH3aYGQ.mjs} +1 -1
- package/dist/{db-CqfT6lhV.mjs → db-DyLzzxvM.mjs} +38 -38
- package/dist/{db-types-DRmxBJ2K.mjs → db-types-DdHHUVPy.mjs} +1 -1
- package/dist/{delete-CY4L8fi2.mjs → delete-Dey6YoMA.mjs} +5 -5
- package/dist/{deploy-La_Ly8g_.mjs → deploy-Ccw2D2lw.mjs} +491 -109
- package/dist/deploy-DEZkUS77.mjs +2 -0
- package/dist/{deploy-managed-static-CESLfKHN.mjs → deploy-managed-static-BBVtpuGv.mjs} +16 -16
- package/dist/{deploy-transport-DcI6LXhY.mjs → deploy-transport-Dt0IvSVW.mjs} +2 -2
- package/dist/deploy.mjs +8 -8
- package/dist/{dispatch-DM4Xdd2l.mjs → dispatch-pYaww76u.mjs} +4 -4
- package/dist/{dist-D23AAMxT.mjs → dist-BQdgCVQF.mjs} +1 -1
- package/dist/{dist-eV_Ep60B.mjs → dist-DeTdhbZc.mjs} +1 -1
- package/dist/{domain-BD1KOQL3.mjs → domain-Dh3mG8Vs.mjs} +6 -6
- package/dist/{email-XAspopcj.mjs → email-DKyMjOYM.mjs} +10 -10
- package/dist/{email-cloudflare-RxIQoPc9.mjs → email-cloudflare-CTt2n_W2.mjs} +13 -9
- package/dist/{env-DrYUh55t.mjs → env-DkZzh_Dd.mjs} +7 -7
- package/dist/env-mask-D31Qztl9.mjs +46 -0
- package/dist/{env-validation-Del3C8AY.mjs → env-validation-1snjKtDX.mjs} +4 -4
- package/dist/{env-validation-Bosj7EVg.mjs → env-validation-C8NL3lEH.mjs} +1 -1
- package/dist/{fetch-C8yhLoF3.mjs → fetch-CAIVkLvW.mjs} +1 -1
- package/dist/{fetch-B-gLGYVl.d.mts → fetch-CbI6lNnk.d.mts} +6 -4
- package/dist/{fetch-stream-DafNtVJC.mjs → fetch-stream-6Op0qlLd.mjs} +1 -1
- package/dist/{fetch-stream-DuwxWmBM.d.mts → fetch-stream-DoED9atq.d.mts} +1 -1
- package/dist/{gen-DSkScMIz.mjs → gen-BZmFOGDQ.mjs} +7 -7
- package/dist/gen-C6iknRdI.mjs +1 -0
- package/dist/{github-cmd-CA-lBdkn.mjs → github-cmd-7Oky9qgH.mjs} +6 -6
- package/dist/{handler-DnI_au0K.mjs → handler-C9SnmeW1.mjs} +5 -4
- package/dist/{handler-BR6Tvjkp.d.mts → handler-DjqciiDc.d.mts} +20 -7
- package/dist/{headers--cbz6iZ8.mjs → headers-CimYIfQI.mjs} +1 -1
- package/dist/{help-1OCFDsRr.mjs → help-CNuUb47C.mjs} +7 -3
- package/dist/help-C_cqTByy.mjs +1 -0
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +154 -109
- package/dist/{info-BpxpsX0B.mjs → info-DwB8IWIx.mjs} +4 -4
- package/dist/{init-DpVXO5S-.mjs → init-CUGSmcED.mjs} +33 -31
- package/dist/{link-DAXOT-G_.mjs → link-BlRTGHan.mjs} +6 -6
- package/dist/{list-BFQ0gcML.mjs → list-iCg7d5Pa.mjs} +7 -7
- package/dist/{live-DF4HUl2m.mjs → live-CYJ4KGoR.mjs} +2 -2
- package/dist/{live-0xrcVpyq.d.mts → live-zKGbRT4h.d.mts} +2 -2
- package/dist/{local-d1-CLVPP6v7.mjs → local-d1-CFcH9Bx3.mjs} +2 -2
- package/dist/login-C4q1S-5b.mjs +1 -0
- package/dist/{login-RIw7ffPe.mjs → login-TA51e5Fw.mjs} +5 -5
- package/dist/{logs-B2OeLS4X.mjs → logs-BlyAxlvx.mjs} +6 -6
- package/dist/{migrate-DiI50Chz.mjs → migrate-BH6LCr00.mjs} +5 -5
- package/dist/migrate-CVBsSFhC.mjs +1 -0
- package/dist/nitro.d.mts +5 -0
- package/dist/nitro.mjs +27 -8
- package/dist/{node-Bc-dBAGL.mjs → node-B0otYjDv.mjs} +4 -4
- package/dist/{operator-args-D79WQP70.mjs → operator-args-DuKAQ3Ks.mjs} +1 -1
- package/dist/{operator-auth-CfDcmzpo.mjs → operator-auth-CD3pap65.mjs} +1 -1
- package/dist/{operator-client-BIY4-N_6.mjs → operator-client-XvXTkea6.mjs} +2 -2
- package/dist/{operator-cmd-CEI5Aaza.mjs → operator-cmd-CoHlJjcT.mjs} +7 -7
- package/dist/operator-cmd-DnaCnCSP.mjs +1 -0
- package/dist/output-CNsMDEd2.mjs +1 -0
- package/dist/{output-BCdLioKP.mjs → output-CXJTIAtF.mjs} +1 -1
- package/dist/pages/client.d.mts +16 -13
- package/dist/pages/client.mjs +34 -66
- package/dist/pages/index.d.mts +4 -3
- package/dist/pages/index.mjs +6 -6
- package/dist/pages/islands-plugin.mjs +1 -1
- package/dist/pages/protocol.d.mts +2 -2
- package/dist/pages/protocol.mjs +1 -1
- package/dist/pages/serialize.d.mts +2 -2
- package/dist/pages/serialize.mjs +1 -1
- package/dist/platform-args-B7-wQ0_B.mjs +1 -0
- package/dist/{platform-args-Cx1M-7bq.mjs → platform-args-DfT8yQBF.mjs} +1 -1
- package/dist/{platform-auth-config-ZrYm8KVs.mjs → platform-auth-config-MO0VdVs9.mjs} +10 -10
- package/dist/{platform-auth-protection-t6mdY4nn.mjs → platform-auth-protection-Dv208eyL.mjs} +8 -8
- package/dist/{platform-auth-recovery-XeBmPTXx.mjs → platform-auth-recovery-DvAQ674F.mjs} +7 -7
- package/dist/{platform-cmd-C7BevP9b.mjs → platform-cmd-BpUA19r_.mjs} +1 -1
- package/dist/{platform-cmd-EXehmSYA.mjs → platform-cmd-dlSxrcQ7.mjs} +9 -9
- package/dist/{platform-domain-DR263ObA.mjs → platform-domain-DSO4eUEw.mjs} +5 -5
- package/dist/{platform-lifecycle-BvU_TNji.mjs → platform-lifecycle-BSvsyB_x.mjs} +17 -17
- package/dist/{platform-lifecycle-CN4aXldN.mjs → platform-lifecycle-CfcFygHb.mjs} +1 -1
- package/dist/{platform-management-yS2sve3V.mjs → platform-management-BMdyt667.mjs} +1 -1
- package/dist/{platform-management-_UE1_GM8.mjs → platform-management-CrP1XhVd.mjs} +4 -4
- package/dist/{platform-plans-config-Dx1agneU.mjs → platform-plans-config-CgDiwflR.mjs} +5 -5
- package/dist/{platform-recovery-CPVk9-Q4.mjs → platform-recovery-CHWwXVZ6.mjs} +3 -3
- package/dist/{platform-setup-Vw1AaUN8.mjs → platform-setup-BTQVbnTC.mjs} +3 -3
- package/dist/{plugin-inference-bQ1Be840.mjs → plugin-inference-g66Q1Mx9.mjs} +4 -4
- package/dist/prepare-Bx4a8cb1.mjs +1 -0
- package/dist/{prepare-BkRhDnxw.mjs → prepare-DJYHjpzq.mjs} +3 -3
- package/dist/{prepare-D8L9AQbw.mjs → prepare-DXduEwQp.mjs} +11 -8
- package/dist/{prerender-render-RlAj6hh8.mjs → prerender-render-BN9Lmebs.mjs} +29 -13
- package/dist/prerender-render.d.mts +10 -2
- package/dist/prerender-render.mjs +1 -1
- package/dist/{project-cmd-DH3CuFC6.mjs → project-cmd-Dfb1Sg8w.mjs} +18 -18
- package/dist/{project-team-MjT5K4rQ.mjs → project-team-BO2dyc7S.mjs} +5 -5
- package/dist/{project-token-BKHGwY3k.mjs → project-token-ByO2mEI2.mjs} +5 -5
- package/dist/{project-tsconfig-BMveFb4b.mjs → project-tsconfig-nhnTWO_Y.mjs} +3 -1
- package/dist/{project-zero-trust-Bzdd05-h.mjs → project-zero-trust-CoQfwRBR.mjs} +5 -5
- package/dist/{protocol-CkwjASep.d.mts → protocol-xZMvWsrg.d.mts} +5 -3
- package/dist/{protocol-COyySMki.mjs → protocol-yxdHxFLN.mjs} +47 -11
- package/dist/{provision-CYhZR_Mn.mjs → provision-CMH4-8ri.mjs} +1 -1
- package/dist/{provision-B0HqoRuI.mjs → provision-D5q-ptD3.mjs} +2 -2
- package/dist/{requests-daJmVpjk.mjs → requests-CPOiDkjh.mjs} +4 -4
- package/dist/resolve-project-BALVa9q0.mjs +1 -0
- package/dist/{resolve-project-D0YNnJfm.mjs → resolve-project-ClvLMTI9.mjs} +1 -1
- package/dist/{rollback-AVwiMAkk.mjs → rollback-BfCs2la4.mjs} +7 -7
- package/dist/{route-types-e69EqY88.mjs → route-types-Cl3x0Q8B.mjs} +265 -12
- package/dist/{route-url-C_YIH_zO.d.mts → route-url-C3JwYrER.d.mts} +8 -3
- package/dist/{route-url-CRDF-I0I.mjs → route-url-CfCR4oMj.mjs} +4 -3
- package/dist/routes-stub.d.mts +10 -1
- package/dist/routes-stub.mjs +1 -1
- package/dist/{runner-QMeOpScZ.mjs → runner-CTk21HrO.mjs} +1 -1
- package/dist/{runner-mysql-0zVmB1JW.mjs → runner-mysql-CHvEg_sy.mjs} +1 -1
- package/dist/runtime/ai.mjs +1 -1
- package/dist/runtime/auth.d.mts +2 -2
- 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 +3 -3
- package/dist/runtime/client-react.mjs +2 -2
- package/dist/runtime/client-solid.d.mts +3 -3
- package/dist/runtime/client-solid.mjs +2 -2
- package/dist/runtime/client-svelte.d.mts +3 -3
- package/dist/runtime/client-svelte.mjs +2 -2
- package/dist/runtime/client-vue.d.mts +3 -3
- package/dist/runtime/client-vue.mjs +2 -2
- package/dist/runtime/client.d.mts +3 -3
- package/dist/runtime/client.mjs +2 -2
- package/dist/runtime/email/testing.mjs +2 -2
- package/dist/runtime/email.mjs +3 -3
- package/dist/runtime/env-public.mjs +2 -46
- package/dist/runtime/fetch-server.d.mts +1 -1
- package/dist/runtime/fetch-server.mjs +1 -1
- package/dist/runtime/fetch-stream.d.mts +2 -2
- package/dist/runtime/fetch-stream.mjs +1 -1
- package/dist/runtime/fetch.d.mts +1 -1
- package/dist/runtime/fetch.mjs +1 -1
- package/dist/runtime/handler.d.mts +1 -1
- package/dist/runtime/handler.mjs +1 -1
- package/dist/runtime/isr.d.mts +3 -1
- package/dist/runtime/live-client.d.mts +11 -2
- package/dist/runtime/live-client.mjs +8 -0
- 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/log.mjs +1 -1
- package/dist/runtime/remote/index.mjs +1 -1
- package/dist/runtime/route-url.d.mts +2 -2
- package/dist/runtime/route-url.mjs +1 -1
- package/dist/runtime/routing.d.mts +15 -4
- package/dist/runtime/routing.mjs +93 -11
- package/dist/runtime/sandbox.mjs +1 -1
- package/dist/runtime/sse-client.d.mts +9 -1
- package/dist/runtime/sse-client.mjs +7 -0
- package/dist/runtime/validator.d.mts +1 -1
- package/dist/runtime/validator.mjs +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/runtime/ws.mjs +1 -1
- package/dist/{scan-F0psanp7.mjs → scan-L8OSv1f7.mjs} +10 -7
- package/dist/{secret-szNdoeKa.mjs → secret-CuI6LTpD.mjs} +7 -7
- package/dist/serialize-DN-envGQ.d.mts +18 -0
- package/dist/serialize-Pf-CIQK_.mjs +39 -0
- package/dist/{skills-D393E4lB.mjs → skills-BBO9wMjB.mjs} +1 -1
- package/dist/{subcommand-prompt-CxJXporl.mjs → subcommand-prompt-BZMnCA8T.mjs} +2 -2
- package/dist/url-CuoEn0o3.mjs +43 -0
- package/dist/validator-8-NZs2Xr.mjs +168 -0
- package/dist/{version-metadata-BC3LK7Y-.mjs → version-metadata-eUd6Ar_U.mjs} +1 -1
- package/dist/wrangler-R3kMdJfw.mjs +1 -0
- package/dist/{wrangler-Gn4EoY4-.mjs → wrangler-k40T7XTQ.mjs} +2 -2
- package/dist/{wrapper-B9W9RE8z.mjs → wrapper-BGsi_uHs.mjs} +11 -8
- package/dist/{ws-Dmjg5NH2.d.mts → ws-DB8Feytg.d.mts} +2 -2
- package/docs/guide/ai.md +2 -0
- package/docs/guide/auth.md +62 -0
- package/docs/guide/database.md +33 -0
- package/docs/guide/deployment.md +8 -0
- package/docs/guide/edge/prerendering.md +9 -4
- package/docs/guide/edge/revalidation.md +3 -0
- package/docs/guide/live.md +2 -0
- package/docs/guide/pages-routing/actions-and-forms.md +15 -10
- package/docs/guide/pages-routing/head.md +3 -1
- package/docs/guide/pages-routing/islands.md +1 -1
- package/docs/guide/pages-routing/loaders.md +2 -0
- package/docs/guide/pages-routing/markdown.md +2 -2
- package/docs/guide/pages-routing/overview.md +139 -10
- package/docs/guide/quickstart.md +1 -0
- package/docs/guide/sse.md +2 -0
- package/docs/guide/ssg.md +23 -2
- package/docs/guide/storage.md +6 -2
- package/docs/guide/type-safety.md +307 -26
- package/docs/guide/typed-fetch.md +7 -3
- package/docs/guide/websockets.md +5 -5
- package/docs/integrations/cloudflare.md +10 -10
- package/docs/integrations/frameworks/nuxt.md +2 -0
- package/docs/integrations/frameworks/overview.md +2 -0
- package/docs/integrations/nodejs-bun-deno.md +65 -0
- package/docs/reference/api/auth.md +19 -0
- package/docs/reference/api/client.md +6 -4
- package/docs/reference/api/handlers.md +3 -1
- package/docs/reference/api/pages.md +8 -8
- package/docs/reference/api/resources.md +3 -1
- package/docs/reference/api/rewrites.md +16 -4
- package/docs/reference/api/types.md +9 -2
- package/docs/reference/cli/database.md +2 -0
- package/docs/reference/cli/deploy.md +17 -11
- package/docs/reference/cli.md +3 -0
- package/docs/reference/config.md +24 -2
- package/package.json +25 -23
- package/schema.json +4 -0
- package/skills/void/SKILL.md +5 -0
- package/dist/cf-build-output-CmDOcA7K.mjs +0 -1
- package/dist/client-CEtr5UOR.mjs +0 -1
- package/dist/deploy-DMhOyebt.mjs +0 -2
- package/dist/gen-BbT1Ku1P.mjs +0 -1
- package/dist/help-Ba8Dq5-r.mjs +0 -1
- package/dist/login-BX2gzHUt.mjs +0 -1
- package/dist/migrate-CUGMGaIM.mjs +0 -1
- package/dist/operator-cmd-oTT2MA9G.mjs +0 -1
- package/dist/output-E6gecbbV.mjs +0 -1
- package/dist/platform-args-C7XUw9mw.mjs +0 -1
- package/dist/prepare-CZRVGNld.mjs +0 -1
- package/dist/resolve-project-CgfjtOwz.mjs +0 -1
- package/dist/serialize-DUuYuaY3.mjs +0 -29
- package/dist/serialize-I4EmS-Wf.d.mts +0 -16
- package/dist/validator-CTfmzZYb.mjs +0 -69
- package/dist/wrangler-CQ5c-MtJ.mjs +0 -1
- package/dist/{cf-access-BmBT2h8_.mjs → cf-access-Dnyw8KFY.mjs} +1 -1
- package/dist/{config-s6TkpSat.mjs → config-eeDzKBS9.mjs} +1 -1
- package/dist/{entry-DFBca6aS.mjs → entry-Bw-G1VVx.mjs} +1 -1
- package/dist/{env-types-Bd8DkQhl.mjs → env-types-Dz9qkiOn.mjs} +1 -1
- package/dist/{inbound-CdO-qY0w.mjs → inbound-C2H6Dzz1.mjs} +2 -2
- package/dist/{runner-5MCSimKx.mjs → runner-CMZb7jNU.mjs} +1 -1
- package/dist/{runner-mysql-Bdmsp_x4.mjs → runner-mysql-BXfcQQj3.mjs} +1 -1
|
@@ -61,14 +61,46 @@ export const loader = defineHandler(async (c) => {
|
|
|
61
61
|
});
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
::: code-group
|
|
65
|
+
|
|
66
|
+
```tsx [React]
|
|
67
|
+
// pages/users/index.tsx
|
|
68
|
+
import type { Props } from './index.server';
|
|
69
|
+
|
|
70
|
+
export default function UsersPage({ users }: Props) {
|
|
71
|
+
// users: { id: number; name: string; ... }[]
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```vue [Vue]
|
|
65
76
|
<!-- pages/users/index.vue -->
|
|
66
77
|
<script setup lang="ts">
|
|
67
78
|
import type { Props } from './index.server';
|
|
68
|
-
|
|
79
|
+
|
|
80
|
+
const { users } = defineProps<Props>(); // users: { id: number; name: string; ... }[]
|
|
81
|
+
</script>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```svelte [Svelte]
|
|
85
|
+
<!-- pages/users/index.svelte -->
|
|
86
|
+
<script lang="ts">
|
|
87
|
+
import type { Props } from './index.server';
|
|
88
|
+
|
|
89
|
+
let { users }: Props = $props(); // users: { id: number; name: string; ... }[]
|
|
69
90
|
</script>
|
|
70
91
|
```
|
|
71
92
|
|
|
93
|
+
```tsx [Solid]
|
|
94
|
+
// pages/users/index.tsx
|
|
95
|
+
import type { Props } from './index.server';
|
|
96
|
+
|
|
97
|
+
export default function UsersPage(props: Props) {
|
|
98
|
+
// props.users: { id: number; name: string; ... }[]
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
:::
|
|
103
|
+
|
|
72
104
|
No manual interface is needed. Props stay in sync with whatever the loader returns.
|
|
73
105
|
|
|
74
106
|
## Action → useForm
|
|
@@ -95,8 +127,8 @@ form.errors.foo; // ✗ TypeScript error
|
|
|
95
127
|
[Named actions](./pages-routing/actions-and-forms#named-actions) work the same way. The `?actionName` suffix selects the right types for that action:
|
|
96
128
|
|
|
97
129
|
```ts
|
|
98
|
-
const updateForm = useForm('/users
|
|
99
|
-
const deleteForm = useForm('/users
|
|
130
|
+
const updateForm = useForm('/users/[id]?update', { name: '' }, { params: { id } });
|
|
131
|
+
const deleteForm = useForm('/users/[id]?delete', { id: '' }, { params: { id } });
|
|
100
132
|
// Each form's data and errors are typed from their respective validators
|
|
101
133
|
```
|
|
102
134
|
|
|
@@ -104,12 +136,12 @@ The `action()` helper gets the same type checking. See [Actions & Forms](./pages
|
|
|
104
136
|
|
|
105
137
|
## Typed URLs and Navigation
|
|
106
138
|
|
|
107
|
-
Use `routeUrl()` from `void/routes` to build URLs from your app's page, HTTP, and WebSocket route patterns. For a page at `pages/users/[id].tsx`, the pattern is `/users
|
|
139
|
+
Use `routeUrl()` from `void/routes` to build URLs from your app's page, HTTP, and WebSocket route patterns. For a page at `pages/users/[id].tsx`, `.vue`, or `.svelte`, the pattern is `/users/[id]`:
|
|
108
140
|
|
|
109
141
|
```ts
|
|
110
142
|
import { routeUrl } from 'void/routes';
|
|
111
143
|
|
|
112
|
-
const url = routeUrl('/users
|
|
144
|
+
const url = routeUrl('/users/[id]', {
|
|
113
145
|
params: { id: 42 },
|
|
114
146
|
query: { tab: 'activity' },
|
|
115
147
|
hash: 'details',
|
|
@@ -119,13 +151,15 @@ const url = routeUrl('/users/:id', {
|
|
|
119
151
|
|
|
120
152
|
Your editor autocompletes route patterns and parameter names. TypeScript checks that the route exists and all required parameters are supplied. Parameter values accept strings or numbers; Void encodes them for the URL. Query keys are chosen by your app, and values can be strings, numbers, booleans, or arrays of those values. Arrays become repeated query parameters; `null` and `undefined` values are omitted.
|
|
121
153
|
|
|
154
|
+
Use bracket patterns with `routeUrl()`, typed `fetch()`, WebSocket `connect()`, page actions, and `useParams()`.
|
|
155
|
+
|
|
122
156
|
Pass the returned string to `Link`, a plain `<a>`, or `c.redirect()`. For programmatic navigation and `c.rewrite()`, you can pass a destination object directly:
|
|
123
157
|
|
|
124
158
|
```ts
|
|
125
159
|
import type { RouteDestination } from 'void/routes';
|
|
126
160
|
|
|
127
161
|
const profile = {
|
|
128
|
-
pathname: '/users
|
|
162
|
+
pathname: '/users/[id]',
|
|
129
163
|
params: { id: 42 },
|
|
130
164
|
query: { tab: 'activity' },
|
|
131
165
|
hash: 'details',
|
|
@@ -134,16 +168,109 @@ const profile = {
|
|
|
134
168
|
|
|
135
169
|
Destination objects use the same parameter checking and URL encoding as `routeUrl()`. See [Pages Routing](./pages-routing/overview.md#typed-navigation) for links and router methods, and [Rewrites](../reference/api/rewrites.md#c-rewrite-destination) for server navigation.
|
|
136
170
|
|
|
137
|
-
For a catch-all page such as `pages/files/[...path].tsx`, use `/files
|
|
171
|
+
For a catch-all page such as `pages/files/[...path].tsx`, `.vue`, or `.svelte`, use `/files/[...path]` and pass the full path as one value:
|
|
138
172
|
|
|
139
173
|
```ts
|
|
140
|
-
routeUrl('/files
|
|
174
|
+
routeUrl('/files/[...path]', { params: { path: 'docs/get started' } });
|
|
141
175
|
// /files/docs/get%20started
|
|
142
176
|
```
|
|
143
177
|
|
|
178
|
+
For an unnamed catch-all (`[...]`), pass its value under the `'*'` key:
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
routeUrl('/files/[...]', { params: { '*': 'docs/get started' } });
|
|
182
|
+
// /files/docs/get%20started
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Page params
|
|
186
|
+
|
|
187
|
+
Pass a page's URL pattern as the type argument of `useParams()` to type the params it reads. For a page at `pages/users/[id].tsx`, `.vue`, or `.svelte`, the pattern is `/users/[id]`:
|
|
188
|
+
|
|
189
|
+
::: code-group
|
|
190
|
+
|
|
191
|
+
```tsx [React]
|
|
192
|
+
import { useParams } from '@void/react';
|
|
193
|
+
|
|
194
|
+
const { id } = useParams<'/users/[id]'>(); // id: string
|
|
195
|
+
useParams<'/users/[id]'>().idd; // Type error: no such param
|
|
196
|
+
useParams<'/userz/[id]'>(); // Type error: no page matches
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
```vue [Vue]
|
|
200
|
+
<script setup lang="ts">
|
|
201
|
+
import { useParams } from '@void/vue';
|
|
202
|
+
|
|
203
|
+
const params = useParams<'/users/[id]'>();
|
|
204
|
+
params.id; // string
|
|
205
|
+
params.idd; // Type error: no such param
|
|
206
|
+
useParams<'/userz/[id]'>(); // Type error: no page matches
|
|
207
|
+
</script>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
```svelte [Svelte]
|
|
211
|
+
<script lang="ts">
|
|
212
|
+
import { useParams } from '@void/svelte';
|
|
213
|
+
|
|
214
|
+
const params = useParams<'/users/[id]'>();
|
|
215
|
+
params.id; // string
|
|
216
|
+
params.idd; // Type error: no such param
|
|
217
|
+
useParams<'/userz/[id]'>(); // Type error: no page matches
|
|
218
|
+
</script>
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
```tsx [Solid]
|
|
222
|
+
import { useParams } from '@void/solid';
|
|
223
|
+
|
|
224
|
+
const params = useParams<'/users/[id]'>();
|
|
225
|
+
params.id; // string
|
|
226
|
+
params.idd; // Type error: no such param
|
|
227
|
+
useParams<'/userz/[id]'>(); // Type error: no page matches
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
:::
|
|
231
|
+
|
|
232
|
+
The pattern must be one of your pages; HTTP and WebSocket routes are not accepted. A catch-all page such as `pages/files/[...path].tsx`, `.vue`, or `.svelte` gives `{ path: string }`. An unnamed catch-all (`[...].tsx`, `[...].vue`, or `[...].svelte`) has no params.
|
|
233
|
+
|
|
234
|
+
The pattern is checked by TypeScript only. Pass the pattern of the page the component renders in; without a pattern, `useParams()` returns `Record<string, string>`.
|
|
235
|
+
|
|
236
|
+
On the server, `c.req.param('slug')` accepts any name. Read the params object through `PageParams` so a missing or misspelled name is a type error:
|
|
237
|
+
|
|
238
|
+
```ts
|
|
239
|
+
import type { PageParams } from 'void/routes';
|
|
240
|
+
|
|
241
|
+
const { slug } = c.req.param() as PageParams<'/posts/[slug]'>;
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Prerender paths
|
|
245
|
+
|
|
246
|
+
On a dynamic page, annotate `getPrerenderPaths()` with `PageParams` for that page's URL pattern. Each returned object must then include the page's params, and a missing or misspelled key is a type error. Void does not infer this type from the filename, so the check applies only when the annotation is present:
|
|
247
|
+
|
|
248
|
+
```ts
|
|
249
|
+
// pages/blog/[slug].server.ts
|
|
250
|
+
import type { PageParams } from 'void/routes';
|
|
251
|
+
|
|
252
|
+
export async function getPrerenderPaths(): Promise<PageParams<'/blog/[slug]'>[]> {
|
|
253
|
+
return [{ slug: 'hello-world' }];
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
In custom SSR mode the function returns full path strings, so annotate it as `Promise<string[]>`. See [Edge Prerendering](./edge/prerendering.md#dynamic-pages-with-params) and [Static Site Generation](./ssg.md#per-page-overrides).
|
|
258
|
+
|
|
259
|
+
`routing.prerender` is a list of plain strings. Annotate the array with `satisfies RouteUrl[]` so each path has to match a route. The check applies when [`routing.typedRoutes`](../reference/config.md#routing-typedroutes) is on; otherwise `RouteUrl` is `string`:
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
// void.config.ts
|
|
263
|
+
import { defineConfig } from 'void/config';
|
|
264
|
+
import type { RouteUrl } from 'void/routes';
|
|
265
|
+
|
|
266
|
+
export default defineConfig({
|
|
267
|
+
routing: { prerender: ['/', '/blog/hello-world'] satisfies RouteUrl[] },
|
|
268
|
+
});
|
|
269
|
+
```
|
|
270
|
+
|
|
144
271
|
### Checked URL strings
|
|
145
272
|
|
|
146
|
-
[`routing.typedRoutes`](../reference/config.md#routing-typedroutes) checks plain URL strings in `Link`'s `href`, `router.visit()`, `router.prefetch()`, `router.flush()`,
|
|
273
|
+
[`routing.typedRoutes`](../reference/config.md#routing-typedroutes) checks plain URL strings in `Link`'s `href`, `router.visit()`, `router.prefetch()`, `router.flush()`, `c.rewrite()`, `c.redirect()`, `revalidate({ paths })`, `connectEventStream()`, `connectLiveStream()`, and `useIslandForm()`'s `post()`, `put()`, `patch()`, `delete()`, and `submit()`. Apps created with `void init` have it on. To turn it on in an existing app:
|
|
147
274
|
|
|
148
275
|
```ts
|
|
149
276
|
// void.config.ts
|
|
@@ -156,44 +283,156 @@ export default defineConfig({
|
|
|
156
283
|
|
|
157
284
|
A string must then match one of your routes, optionally followed by a query string or hash:
|
|
158
285
|
|
|
159
|
-
|
|
286
|
+
::: code-group
|
|
287
|
+
|
|
288
|
+
```tsx [React]
|
|
289
|
+
import { Link } from '@void/react';
|
|
290
|
+
import { routeUrl } from 'void/routes';
|
|
291
|
+
|
|
292
|
+
<Link href="/about">About</Link>
|
|
293
|
+
<Link href={`/users/${user.id}?tab=activity`}>Profile</Link>
|
|
294
|
+
<Link href={routeUrl('/users/[id]', { params: { id } })}>Profile</Link>
|
|
295
|
+
<Link href="/abuot">About</Link> // Type error: no route matches
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
```vue [Vue]
|
|
299
|
+
<script setup lang="ts">
|
|
300
|
+
import { Link } from '@void/vue';
|
|
301
|
+
import { routeUrl } from 'void/routes';
|
|
302
|
+
</script>
|
|
303
|
+
|
|
304
|
+
<template>
|
|
305
|
+
<Link href="/about">About</Link>
|
|
306
|
+
<Link :href="`/users/${user.id}?tab=activity`">Profile</Link>
|
|
307
|
+
<Link :href="routeUrl('/users/[id]', { params: { id } })">Profile</Link>
|
|
308
|
+
<!-- Type error: no route matches -->
|
|
309
|
+
<Link href="/abuot">About</Link>
|
|
310
|
+
</template>
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
```svelte [Svelte]
|
|
314
|
+
<script lang="ts">
|
|
315
|
+
import { Link } from '@void/svelte';
|
|
316
|
+
import { routeUrl } from 'void/routes';
|
|
317
|
+
</script>
|
|
318
|
+
|
|
160
319
|
<Link href="/about">About</Link>
|
|
161
320
|
<Link href={`/users/${user.id}?tab=activity`}>Profile</Link>
|
|
162
|
-
<Link href={routeUrl('/users
|
|
321
|
+
<Link href={routeUrl('/users/[id]', { params: { id } })}>Profile</Link>
|
|
322
|
+
<!-- Type error: no route matches -->
|
|
323
|
+
<Link href="/abuot">About</Link>
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
```tsx [Solid]
|
|
327
|
+
import { Link } from '@void/solid';
|
|
328
|
+
import { routeUrl } from 'void/routes';
|
|
329
|
+
|
|
330
|
+
<Link href="/about">About</Link>
|
|
331
|
+
<Link href={`/users/${user.id}?tab=activity`}>Profile</Link>
|
|
332
|
+
<Link href={routeUrl('/users/[id]', { params: { id } })}>Profile</Link>
|
|
163
333
|
<Link href="/abuot">About</Link> // Type error: no route matches
|
|
164
334
|
```
|
|
165
335
|
|
|
166
|
-
|
|
336
|
+
:::
|
|
337
|
+
|
|
338
|
+
Links can also point to the current page (`?page=2`, `#comments`) and to `http://`, `https://`, `mailto:`, and `tel:` URLs. Relative paths such as `../settings` are rejected; use the absolute path. A fixed part with spaces or non-ASCII characters can be written as is (`/café menu`) or percent-encoded in uppercase, as `routeUrl()` returns it (`/caf%C3%A9%20menu`). A dynamic segment matches any text, including none, so `/users/[id]` also accepts `/users/` and `/users/42/edit`. With a root dynamic page such as `pages/[slug].tsx`, `.vue`, or `.svelte`, a protocol-relative URL like `//example.com` passes too.
|
|
339
|
+
|
|
340
|
+
The [SSE](./sse.md#client) and [live stream](./live.md#subscribe-from-the-browser) clients, `connectEventStream()` and `connectLiveStream()`, take one of your routes or an `http://` or `https://` URL for a stream on another origin. They reject same-page, `mailto:`, `tel:`, and `ws://` URLs. Cast a stream URL that TypeScript can't check with `as RouteUrl`; the cast turns off the check for that URL.
|
|
341
|
+
|
|
342
|
+
`c.redirect()` uses the same check as links. With `routing.typedRoutes` on, the location is a route URL, a same-page query or hash (`?page=2`, `#comments`), or an `http://`, `https://`, `mailto:`, or `tel:` URL. A path that matches no route is a type error. An external `https://` literal needs no cast. A `URL` or a destination object is accepted too. Cast a string TypeScript cannot check, such as a URL from a provider SDK, your CMS, or a file in `public/`, with `as Href`:
|
|
343
|
+
|
|
344
|
+
```ts
|
|
345
|
+
import { routeUrl, type Href } from 'void/routes';
|
|
346
|
+
|
|
347
|
+
declare const id: string;
|
|
348
|
+
declare const dynamic: string;
|
|
349
|
+
|
|
350
|
+
c.redirect('/about');
|
|
351
|
+
c.redirect(routeUrl('/users/[id]', { params: { id } }));
|
|
352
|
+
c.redirect({ pathname: '/users/[id]', params: { id } });
|
|
353
|
+
c.redirect('https://example.com/login');
|
|
354
|
+
c.redirect(new URL('https://example.com/login'));
|
|
355
|
+
c.redirect(dynamic as Href);
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
The cast turns the check off, so cast only URLs you trust. Check a URL from the request, such as a `?redirectTo=` parameter, before redirecting to it. See [`c.redirect()`](../reference/api/rewrites.md#c-rewrite-destination).
|
|
167
359
|
|
|
168
360
|
`void/routes` exports two types for these strings:
|
|
169
361
|
|
|
170
|
-
- `RouteUrl`: the URL of one of your routes. `routeUrl()` returns it, and `c.rewrite()`
|
|
171
|
-
- `Href`: anything a link can point to: a `RouteUrl`, a same-page query or hash, or an external URL.
|
|
362
|
+
- `RouteUrl`: the URL of one of your routes. `routeUrl()` returns it, and `c.rewrite()`, `useIslandForm()`, and `revalidate({ paths })` accept it. Annotate a `routing.prerender` list with it.
|
|
363
|
+
- `Href`: anything a link or `c.redirect()` can point to: a `RouteUrl`, a same-page query or hash, or an external URL.
|
|
364
|
+
|
|
365
|
+
Cast a string that TypeScript can't check, such as a path from your CMS or a file in `public/`. The cast turns the check off for that string:
|
|
366
|
+
|
|
367
|
+
::: code-group
|
|
368
|
+
|
|
369
|
+
```tsx [React]
|
|
370
|
+
import { Link } from '@void/react';
|
|
371
|
+
import type { Href, RouteUrl } from 'void/routes';
|
|
372
|
+
|
|
373
|
+
<Link href={post.path as RouteUrl}>{post.title}</Link>
|
|
374
|
+
<Link href={user.website as Href}>Website</Link>
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
```vue [Vue]
|
|
378
|
+
<script setup lang="ts">
|
|
379
|
+
import { Link } from '@void/vue';
|
|
380
|
+
import type { Href, RouteUrl } from 'void/routes';
|
|
381
|
+
|
|
382
|
+
const postHref = post.path as RouteUrl;
|
|
383
|
+
const website = user.website as Href;
|
|
384
|
+
</script>
|
|
172
385
|
|
|
173
|
-
|
|
386
|
+
<template>
|
|
387
|
+
<Link :href="postHref">{{ post.title }}</Link>
|
|
388
|
+
<Link :href="website">Website</Link>
|
|
389
|
+
</template>
|
|
390
|
+
```
|
|
174
391
|
|
|
175
|
-
```
|
|
392
|
+
```svelte [Svelte]
|
|
393
|
+
<script lang="ts">
|
|
394
|
+
import { Link } from '@void/svelte';
|
|
395
|
+
import type { Href, RouteUrl } from 'void/routes';
|
|
396
|
+
|
|
397
|
+
const postHref = post.path as RouteUrl;
|
|
398
|
+
const website = user.website as Href;
|
|
399
|
+
</script>
|
|
400
|
+
|
|
401
|
+
<Link href={postHref}>{post.title}</Link>
|
|
402
|
+
<Link href={website}>Website</Link>
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
```tsx [Solid]
|
|
406
|
+
import { Link } from '@void/solid';
|
|
176
407
|
import type { Href, RouteUrl } from 'void/routes';
|
|
177
408
|
|
|
178
409
|
<Link href={post.path as RouteUrl}>{post.title}</Link>
|
|
179
410
|
<Link href={user.website as Href}>Website</Link>
|
|
180
411
|
```
|
|
181
412
|
|
|
413
|
+
:::
|
|
414
|
+
|
|
182
415
|
Restart the dev server or run `void prepare` after changing `routing.typedRoutes`.
|
|
183
416
|
|
|
184
417
|
Route types update with the dev server. For CI or standalone typechecking, run `void prepare` and follow [Setup](#setup). The [API reference](../reference/api/types.md#void-routes) lists the URL helper and route types.
|
|
185
418
|
|
|
186
419
|
## What Gets Checked
|
|
187
420
|
|
|
188
|
-
| Layer
|
|
189
|
-
|
|
|
190
|
-
| Database
|
|
191
|
-
| Handlers
|
|
192
|
-
| Fetch client
|
|
193
|
-
| Navigation
|
|
194
|
-
| Links
|
|
195
|
-
| `
|
|
196
|
-
| `
|
|
421
|
+
| Layer | What's type-checked |
|
|
422
|
+
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
423
|
+
| Database | Table columns, value types, insert/update shapes from Drizzle schema |
|
|
424
|
+
| Handlers | `c.env` bindings, validator input, return type |
|
|
425
|
+
| Fetch client | Route paths, HTTP methods, `body`/`query`/`params`, response type |
|
|
426
|
+
| Navigation | Route patterns and required parameter names and values in `routeUrl()` and destination objects |
|
|
427
|
+
| Links | With `routing.typedRoutes`, URL strings in `Link`, router methods, `c.rewrite()`, `useIslandForm()`, and SSE and live stream clients |
|
|
428
|
+
| `c.redirect` | With `routing.typedRoutes`, route URLs, same-page queries and hashes, destination objects, `URL` values, and `http://`, `https://`, `mailto:`, and `tel:` literals. A string TypeScript cannot check needs `as Href`. |
|
|
429
|
+
| `useParams` | Page patterns and the names of the params they return |
|
|
430
|
+
| `c.req.param` | Page param names, when the result is annotated with `PageParams` |
|
|
431
|
+
| `getPrerenderPaths` | Page param names, when the return type is annotated with `PageParams` |
|
|
432
|
+
| `revalidate` | With `routing.typedRoutes`, URL strings in `paths` |
|
|
433
|
+
| `routing.prerender` | Paths, when the array is annotated with `satisfies RouteUrl[]` |
|
|
434
|
+
| `useForm` | Action URLs, `data` fields, `errors` keys, `reset()` args (including `{ initial: true }`), `params`, `resetOnSuccess` |
|
|
435
|
+
| `action()` | Action URLs, `data` payload, `params` |
|
|
197
436
|
|
|
198
437
|
## Serialization
|
|
199
438
|
|
|
@@ -227,6 +466,48 @@ export default defineMiddleware(async (c, next) => {
|
|
|
227
466
|
|
|
228
467
|
Now `c.get("requestId")` returns `string` everywhere, with no assertion needed. Multiple augmentations across files are [merged together](https://www.typescriptlang.org/docs/handbook/declaration-merging.html).
|
|
229
468
|
|
|
469
|
+
## Custom Binding Types
|
|
470
|
+
|
|
471
|
+
On the Cloudflare target, Void generates types for bindings declared under `cloudflare` in `void.config.ts`. For example, configure a [Cloudflare rate limiter](https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/):
|
|
472
|
+
|
|
473
|
+
```ts
|
|
474
|
+
// void.config.ts
|
|
475
|
+
import { defineConfig } from 'void/config';
|
|
476
|
+
|
|
477
|
+
export default defineConfig({
|
|
478
|
+
cloudflare: {
|
|
479
|
+
ratelimits: [
|
|
480
|
+
{ name: 'MY_RATE_LIMITER', namespace_id: '1001', simple: { limit: 10, period: 60 } },
|
|
481
|
+
],
|
|
482
|
+
},
|
|
483
|
+
});
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
Run `void prepare`, or start the dev server, to use the binding without a type assertion:
|
|
487
|
+
|
|
488
|
+
```ts
|
|
489
|
+
import { defineHandler } from 'void';
|
|
490
|
+
|
|
491
|
+
export const GET = defineHandler(async (c) => {
|
|
492
|
+
const { success } = await c.env.MY_RATE_LIMITER.limit({ key: 'example' });
|
|
493
|
+
return { success };
|
|
494
|
+
});
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
Service bindings use `Fetcher`, Durable Objects use `DurableObjectNamespace`, and other bindings use their standard Cloudflare types. For RPC methods or other specialized types, augment `CloudBindings` in a file included by your tsconfig:
|
|
498
|
+
|
|
499
|
+
```ts
|
|
500
|
+
import type {} from 'void';
|
|
501
|
+
|
|
502
|
+
declare module 'void' {
|
|
503
|
+
interface CloudBindings {
|
|
504
|
+
AUTH: Fetcher & { check(): Promise<boolean> };
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
The declaration can refine a generated binding or type a binding that is not declared in `cloudflare`. Fixed values and secrets declared in `env.ts` retain their schema types. These types apply to Void's `c.env`; use your framework's Cloudflare type setup when accessing bindings through `cloudflare:workers`.
|
|
510
|
+
|
|
230
511
|
## Setup
|
|
231
512
|
|
|
232
513
|
Extend the generated tsconfig in your project:
|
|
@@ -21,11 +21,13 @@ await fetch('/api/users', {
|
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
// Dynamic params interpolated from the route pattern
|
|
24
|
-
const user = await fetch('/api/users
|
|
24
|
+
const user = await fetch('/api/users/[id]', {
|
|
25
25
|
params: { id: '42' },
|
|
26
26
|
});
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
+
Route patterns use the same brackets as your filenames.
|
|
30
|
+
|
|
29
31
|
## What Gets Type-Checked
|
|
30
32
|
|
|
31
33
|
The client constrains every part of the request:
|
|
@@ -35,6 +37,8 @@ The client constrains every part of the request:
|
|
|
35
37
|
- **Body, query, params:** when your handler uses [`defineHandler.withValidator()`](./server-routing.md#validation), validator schemas become the input types and the client enforces them at the call site.
|
|
36
38
|
- **Response type:** the return type matches what your handler returns after [JSON serialization](./type-safety.md#serialization).
|
|
37
39
|
|
|
40
|
+
Omitting `method` sends GET. For a route without a GET handler, specify a supported method, such as `{ method: 'POST' }`.
|
|
41
|
+
|
|
38
42
|
## Query Parameters
|
|
39
43
|
|
|
40
44
|
Pass `query` for GET requests with search parameters:
|
|
@@ -62,7 +66,7 @@ Non-2xx responses throw a `FetchError`:
|
|
|
62
66
|
import { fetch, FetchError } from 'void/client';
|
|
63
67
|
|
|
64
68
|
try {
|
|
65
|
-
await fetch('/api/users
|
|
69
|
+
await fetch('/api/users/[id]', { params: { id: '999' } });
|
|
66
70
|
} catch (e) {
|
|
67
71
|
if (e instanceof FetchError) {
|
|
68
72
|
console.log(e.status); // 404
|
|
@@ -79,7 +83,7 @@ try {
|
|
|
79
83
|
| `method` | `string` | HTTP method. Defaults to `"GET"`. |
|
|
80
84
|
| `body` | `object` | Request body (auto-serialized as JSON). |
|
|
81
85
|
| `query` | `Record<string, string>` | Query string parameters. |
|
|
82
|
-
| `params` | `Record<string, string>` | URL path parameters (
|
|
86
|
+
| `params` | `Record<string, string>` | URL path parameters (`[id]` segments). |
|
|
83
87
|
| `headers` | `HeadersInit` | Additional request headers. |
|
|
84
88
|
| `signal` | `AbortSignal` | Abort signal. |
|
|
85
89
|
| `baseURL` | `string` | Base URL prepended to the path. Useful for external calls. |
|
package/docs/guide/websockets.md
CHANGED
|
@@ -27,7 +27,7 @@ Use `.ws.tsx` or `.ws.jsx` when a handler contains JSX, such as rendering HTML f
|
|
|
27
27
|
Filename rules match regular server routes:
|
|
28
28
|
|
|
29
29
|
- `index.ws.ts` becomes the parent path
|
|
30
|
-
- `[id].ws.ts`
|
|
30
|
+
- `[id].ws.ts` adds a dynamic `[id]` segment
|
|
31
31
|
- `[...slug].ws.ts` becomes a catch-all
|
|
32
32
|
- route groups like `(marketing)/chat.ws.ts` are ignored in the URL
|
|
33
33
|
- `chat.dev.ws.ts` / `chat.prod.ws.ts` restrict the route to one environment
|
|
@@ -122,7 +122,7 @@ Use `connect()` from `void/ws` on the client:
|
|
|
122
122
|
```ts
|
|
123
123
|
import { connect } from 'void/ws';
|
|
124
124
|
|
|
125
|
-
const socket = connect('/chat
|
|
125
|
+
const socket = connect('/chat/[room]', {
|
|
126
126
|
params: { room: 'general' },
|
|
127
127
|
});
|
|
128
128
|
|
|
@@ -200,13 +200,13 @@ export default defineRoom({
|
|
|
200
200
|
});
|
|
201
201
|
```
|
|
202
202
|
|
|
203
|
-
Move the file to `routes/rooms/[room].ws.ts`, update clients to connect to `/rooms
|
|
203
|
+
Move the file to `routes/rooms/[room].ws.ts`, update clients to connect to `/rooms/[room]`, and deploy normally. Keep the same parameter names and values: room `general` still uses its existing storage. The Worker class, binding, and migration history stay the same on both Cloudflare and Void platform deployments.
|
|
204
204
|
|
|
205
205
|
Both `defineRoom()` and `defineWebSocket()` accept optional `name`. Use a static string, inline or in a local `const`. Each route must produce a distinct Worker class; changing the name selects a different resource. If you already moved a route, `void info` also shows unmatched identities recorded in `void.lock.json`. Identify the original resource before adopting its suggested name; otherwise restore the original source and discover the name there.
|
|
206
206
|
|
|
207
207
|
### Rename a route parameter
|
|
208
208
|
|
|
209
|
-
By default, the instance key includes parameter names. `/chat
|
|
209
|
+
By default, the instance key includes parameter names. `/chat/[room]` with `room: 'general'` uses `room=general`; a route without parameters uses `default`. Multiple parameters are joined in route order, for example `team=acme&room=general`. If a multi-parameter route has a value containing `&`, its key uses a versioned encoding to keep rooms separate.
|
|
210
210
|
|
|
211
211
|
If you also rename `[room]` to `[id]`, preserve the old key explicitly:
|
|
212
212
|
|
|
@@ -220,7 +220,7 @@ export default defineRoom({
|
|
|
220
220
|
});
|
|
221
221
|
```
|
|
222
222
|
|
|
223
|
-
Clients now connect to `/rooms
|
|
223
|
+
Clients now connect to `/rooms/[id]` with `params: { id: 'general' }`. The key remains `room=general`, so storage and `ctx.id` stay the same. Returning only `params.id` would select a different instance.
|
|
224
224
|
|
|
225
225
|
`key` is optional on both WebSocket helpers. It must return a string synchronously and consistently for the same parameters. Preserve the complete old key when migrating multiple parameters. Keep the callback stable after deployment.
|
|
226
226
|
|
|
@@ -42,7 +42,7 @@ Add `void/env` to your TypeScript types:
|
|
|
42
42
|
}
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
This provides binding types and Workers runtime types.
|
|
45
|
+
This provides binding types and Workers runtime types. Custom bindings declared in `cloudflare` in `void.config.ts` are typed on `c.env` after `void prepare` or starting a dev server or build. See [Custom Binding Types](../guide/type-safety.md#custom-binding-types) to add RPC methods to service or Durable Object bindings.
|
|
46
46
|
|
|
47
47
|
### Available bindings
|
|
48
48
|
|
|
@@ -133,14 +133,14 @@ Apps using email need `email.from` in `void.config.ts`. Void reviews the domain'
|
|
|
133
133
|
|
|
134
134
|
Set these CI secrets and variables as needed:
|
|
135
135
|
|
|
136
|
-
| Name | When needed
|
|
137
|
-
| ------------------------------------------------ |
|
|
138
|
-
| `CLOUDFLARE_API_TOKEN` | Required. Workers Scripts: Edit, read access to bound resources, and edit access to products Void provisions.
|
|
139
|
-
| `CLOUDFLARE_ACCOUNT_ID` | When the token can access several accounts.
|
|
140
|
-
| `DATABASE_URL` | PostgreSQL and MySQL provisioning and migrations.
|
|
141
|
-
| `CLOUDFLARE_WORKERS_SUBDOMAIN` | When the
|
|
142
|
-
| `CF_ACCESS_CLIENT_ID`, `CF_ACCESS_CLIENT_SECRET` | When Cloudflare Access protects the readiness URL.
|
|
143
|
-
| `CF_ACCESS_READINESS_ORIGIN` | When Access protects a route or Custom Domain and `workers_dev` is `false`. See [Cloudflare Access](#cloudflare-access).
|
|
136
|
+
| Name | When needed |
|
|
137
|
+
| ------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
138
|
+
| `CLOUDFLARE_API_TOKEN` | Required. Workers Scripts: Edit, read access to bound resources, and edit access to products Void provisions. |
|
|
139
|
+
| `CLOUDFLARE_ACCOUNT_ID` | When the token can access several accounts. |
|
|
140
|
+
| `DATABASE_URL` | PostgreSQL and MySQL provisioning and migrations. |
|
|
141
|
+
| `CLOUDFLARE_WORKERS_SUBDOMAIN` | When workers.dev is enabled and the version has no preview URL. Use `my-team` or `my-team.workers.dev`. An account subdomain does not create a readiness URL when `workers_dev` is false. |
|
|
142
|
+
| `CF_ACCESS_CLIENT_ID`, `CF_ACCESS_CLIENT_SECRET` | When Cloudflare Access protects the readiness URL. |
|
|
143
|
+
| `CF_ACCESS_READINESS_ORIGIN` | When Access protects a route or Custom Domain and `workers_dev` is `false`. See [Cloudflare Access](#cloudflare-access). |
|
|
144
144
|
|
|
145
145
|
For email, run `void email setup --platform cloudflare` locally, commit `void.lock.json`, and pass `--require-email` in CI. The token also needs Email Routing Edit and Email Sending Edit.
|
|
146
146
|
|
|
@@ -174,7 +174,7 @@ Set production server values with `void secret put <NAME>`. Void preserves exist
|
|
|
174
174
|
|
|
175
175
|
### Readiness and rollback
|
|
176
176
|
|
|
177
|
-
Void normally verifies an uploaded version before sending it traffic. If readiness or trigger updates fail, it restores the previous deployment. Finish or cancel any gradual rollout in Cloudflare before deploying through Void.
|
|
177
|
+
Void normally verifies an uploaded version before sending it traffic. A Worker with workers.dev turned off and no route or Custom Domain has no URL Void can check, so that deploy skips the readiness check and activates the uploaded version. If readiness or trigger updates fail, it restores the previous deployment. If trigger updates fail and Void cannot restore the previous version's triggers, for example because another tool deployed it or it is an empty draft, the new version stays live and the error says which version is serving traffic. Finish or cancel any gradual rollout in Cloudflare before deploying through Void.
|
|
178
178
|
|
|
179
179
|
For an existing Durable Object Worker that Cloudflare cannot stage, review the changes and use:
|
|
180
180
|
|
|
@@ -48,6 +48,8 @@ export default defineNuxtConfig({
|
|
|
48
48
|
|
|
49
49
|
The `void/nitro` module gives Nuxt server routes your app's `void/db` and `@schema`. The top-level `alias` lets `nuxi typecheck` resolve `@schema`, because Nuxt also checks server routes with the app's types. `cloudflare.dev` gives the development server the bindings from Void's generated Cloudflare config; Nuxt runs it in development when `compatibilityDate` is `2025-07-15` or later.
|
|
50
50
|
|
|
51
|
+
The database module supports Nitro 2 and Nitro 3 prereleases. Keep your Nuxt version's Cloudflare development configuration; Nitro 3 manages local Workers through its development runner.
|
|
52
|
+
|
|
51
53
|
### 4. Create `void.config.ts`
|
|
52
54
|
|
|
53
55
|
Void generates the Cloudflare config used by Nuxt's development runtime:
|
|
@@ -25,6 +25,8 @@ TanStack Start and React Router use the Cloudflare Vite plugin provided by Void.
|
|
|
25
25
|
|
|
26
26
|
Detection is automatic. The CLI reads your `package.json` dependencies.
|
|
27
27
|
|
|
28
|
+
In vinext apps, `middleware.ts` and `proxy.ts` also apply to files in `public/`. When either file is present, static requests go through the Worker and count toward its request usage. Apps without middleware keep static asset delivery.
|
|
29
|
+
|
|
28
30
|
## Feature Support
|
|
29
31
|
|
|
30
32
|
With `voidPlugin()` added to the framework's Vite config, frameworks get most of the same backend/platform features as [Void apps](../../guide/app-types.md#void-apps):
|
|
@@ -160,3 +160,68 @@ console.log(await response.json()); // { message: "Hello from Node.js!" }
|
|
|
160
160
|
```
|
|
161
161
|
|
|
162
162
|
This is useful for testing, embedding in Express/Fastify, or running in serverless environments that accept a `fetch` handler.
|
|
163
|
+
|
|
164
|
+
### Serving the client build from somewhere else
|
|
165
|
+
|
|
166
|
+
By default, `app.js` serves the client build from `dist/client`, next to `dist/ssr`. To serve it from elsewhere, such as from inside a [single executable application](https://nodejs.org/api/single-executable-applications.html), pass an `ASSETS` object with a `fetch(request)` method in the env. Void then reads the client manifest, scripts, styles and `public/` files through it, and doesn't look for `dist/client`.
|
|
167
|
+
|
|
168
|
+
This server reads the client build from a single executable's assets, stored under their URL paths (`/.vite/manifest.json`, `/assets/…`, and `public/` files):
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
import { getAsset } from 'node:sea';
|
|
172
|
+
import { serve } from '@hono/node-server';
|
|
173
|
+
import app from './dist/ssr/app.js';
|
|
174
|
+
|
|
175
|
+
const types: Record<string, string> = {
|
|
176
|
+
'.js': 'text/javascript',
|
|
177
|
+
'.css': 'text/css',
|
|
178
|
+
'.json': 'application/json',
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const ASSETS = {
|
|
182
|
+
async fetch(request: Request): Promise<Response> {
|
|
183
|
+
const { pathname } = new URL(request.url);
|
|
184
|
+
try {
|
|
185
|
+
const type = types[pathname.slice(pathname.lastIndexOf('.'))] ?? 'application/octet-stream';
|
|
186
|
+
return new Response(getAsset(pathname), { headers: { 'content-type': type } });
|
|
187
|
+
} catch {
|
|
188
|
+
return new Response('Not Found', { status: 404 });
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
serve({ fetch: (request, env) => app.fetch(request, { ...env, ASSETS }), port: 3000 });
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Keep the env the server passes in: on Node.js it carries the incoming request, which `getConnInfo()` reads.
|
|
197
|
+
|
|
198
|
+
With Bun, `bun build --compile` embeds a file only when the code imports it with `{ type: 'file' }`. Listing `dist/client` files as extra entry points doesn't work, because Bun bundles JavaScript entry points as code. Client file names change with every build, so write the imports into a module after `vite build`, one per file in `dist/client`:
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
// client-files.ts, written after each `vite build`
|
|
202
|
+
import manifest from './dist/client/.vite/manifest.json' with { type: 'file' };
|
|
203
|
+
import pagesClient from './dist/client/assets/pages-client-BZk7n9j7.js' with { type: 'file' };
|
|
204
|
+
|
|
205
|
+
const files: Record<string, string> = {
|
|
206
|
+
'/.vite/manifest.json': manifest,
|
|
207
|
+
'/assets/pages-client-BZk7n9j7.js': pagesClient,
|
|
208
|
+
};
|
|
209
|
+
export default files;
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Then serve them from the compiled executable, passing Bun's `Server` as `server` so `getConnInfo()` still works:
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
import files from './client-files.ts';
|
|
216
|
+
// server.ts, compiled with `bun build --compile server.ts --outfile server`
|
|
217
|
+
import app from './dist/ssr/app.js';
|
|
218
|
+
|
|
219
|
+
const ASSETS = {
|
|
220
|
+
async fetch(request: Request): Promise<Response> {
|
|
221
|
+
const path = files[new URL(request.url).pathname];
|
|
222
|
+
return path ? new Response(Bun.file(path)) : new Response('Not Found', { status: 404 });
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
Bun.serve({ fetch: (request, server) => app.fetch(request, { server, ASSETS }), port: 3000 });
|
|
227
|
+
```
|