void 0.22.0 → 0.23.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/README.md +5 -1
- package/dist/{account-cmd-CjyxcGkM.mjs → account-cmd-C84Ee8cO.mjs} +4 -4
- package/dist/{scan-ClYmX3sa.mjs → application-analysis-BVsVqc11.mjs} +135 -18
- package/dist/application-routing-B7QEjqSR.mjs +27 -0
- package/dist/{auth-CZuiVsFh.mjs → auth-CCjt0hcq.mjs} +1 -1
- package/dist/{auth-DLNN0D3Z.mjs → auth-CSkdO2Bb.mjs} +4 -47
- package/dist/{auth-link-BLO4ptzo.mjs → auth-link-CioEg6uY.mjs} +4 -4
- package/dist/{auth-router-ZUg9MF_U.mjs → auth-router-BsR981d4.mjs} +4 -4
- package/dist/{better-auth-shared-rsBGBvWJ.mjs → better-auth-shared-hy6RPh9W.mjs} +13 -2
- package/dist/{build-cmd-BxR5FROK.mjs → build-cmd-LzvNJORH.mjs} +17 -5
- package/dist/{cache-D0sWhgKI.mjs → cache-C4MvnrMH.mjs} +2 -2
- package/dist/{cancel-deploy-D4NUqFbi.mjs → cancel-deploy-abUxpP2n.mjs} +2 -2
- package/dist/{cf-build-output-BJ6yGEIS.mjs → cf-build-output-BPqOT964.mjs} +2 -1
- package/dist/cf-build-output-_0HNWysu.mjs +2 -0
- package/dist/cli/cli.mjs +80 -455
- package/dist/cli/{cf-compat.mjs → cloudflare-operation-process.mjs} +442 -421
- package/dist/cli/env-schema-probe.d.mts +2 -1
- package/dist/cli/env-schema-probe.mjs +3 -3
- package/dist/client-Cu7jWiF1.mjs +2 -0
- package/dist/{client-BTZ3XkrB.mjs → client-RV8NVeB8.mjs} +140 -21
- package/dist/{cloudflare-auth-DQkqoMYa.mjs → cloudflare-auth-Qdc7tw8F.mjs} +41 -38
- package/dist/{cloudflare-cmd-BKlfGHAy.mjs → cloudflare-cmd-BcrVyTmJ.mjs} +5 -5
- package/dist/cloudflare-config-Bktvwtpf.mjs +182 -0
- package/dist/{cloudflare-connect-Ctmrw579.mjs → cloudflare-connect-B8uPZ4nx.mjs} +3 -3
- package/dist/{cloudflare-operations-BT6OWFBk.mjs → cloudflare-operations-AiWashgg.mjs} +1 -1
- package/dist/{cloudflare-operations-B9tzgjmf.mjs → cloudflare-operations-fxHb-byx.mjs} +116 -172
- package/dist/{preset-UHj9ARyP.mjs → cloudflare-process-B-wekeR6.mjs} +93 -6
- package/dist/{config-VavjpDnp.d.mts → config-BMHb8RCj.d.mts} +1 -0
- package/dist/config-C_XRIPx2.mjs +89 -0
- package/dist/config-entry.d.mts +1 -1
- package/dist/{connect-Dg-WkW-C.mjs → connect-Bd4kJd9U.mjs} +5 -5
- package/dist/{create-project-DdoqwFLF.mjs → create-project-Boczwj5r.mjs} +1 -1
- package/dist/{create-project-l9J7pbtm.mjs → create-project-bMf6ffLZ.mjs} +2 -2
- package/dist/{db-gp2sCXyN.mjs → db-8uG64XLl.mjs} +21 -21
- package/dist/{delete-TTedbH6B.mjs → delete-NvbiyeJf.mjs} +2 -2
- package/dist/{deploy-CH-o2CaZ.mjs → deploy-DzAIwqNU.mjs} +908 -582
- package/dist/{deploy-B19L2Bra.mjs → deploy-bjXdFCtn.mjs} +1 -1
- package/dist/{domain-JRF59P_r.mjs → domain-y5Tvydvo.mjs} +3 -3
- package/dist/{email-Bo6G9LOZ.mjs → email-B3umsW75.mjs} +13 -28
- package/dist/{env-BYOrWQnv.mjs → env-BS6qYHDb.mjs} +4 -4
- package/dist/{env-public-BxU_0yTL.d.mts → env-public-BX_r8HR6.d.mts} +1 -1
- package/dist/{env-validation-BB4GkLxn.mjs → env-validation-BPn7vk-V.mjs} +18 -71
- package/dist/{env-validation-BXge7uyK.mjs → env-validation-DbTg7-ar.mjs} +1 -1
- package/dist/{fetch-CXDChK7B.mjs → fetch-BIZJh7vR.mjs} +2 -2
- package/dist/{fetch-stream-AOByI7Ki.mjs → fetch-stream-IvCYKyQL.mjs} +24 -4
- package/dist/{gen-sCtlCOdA.mjs → gen-B580--vC.mjs} +2 -2
- package/dist/gen-BVaUUumi.mjs +2 -0
- package/dist/{github-cmd-0-7PexDq.mjs → github-cmd-v45BdfKX.mjs} +2 -2
- package/dist/{handler-HEcZsaij.d.mts → handler-CZ4nAylQ.d.mts} +1 -1
- package/dist/help-DofyZuY7.mjs +2 -0
- package/dist/{help-GKtwl07I.mjs → help-daGKjXGk.mjs} +229 -747
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +288 -1502
- package/dist/info-B97bTX9N.mjs +113 -0
- package/dist/{init-FZx3Elvz.mjs → init-Bvy7zrBo.mjs} +46 -15
- package/dist/limits-Bq5LG8Id.d.mts +27 -0
- package/dist/limits-Cjuk2VPm.mjs +68 -0
- package/dist/{link-BrQfb_CU.mjs → link-CDqqCjFl.mjs} +3 -3
- package/dist/{list-D44jmIAM.mjs → list-CZj0dzKY.mjs} +3 -3
- package/dist/{live-CKJlvlNp.d.mts → live-Chw1eIMv.d.mts} +1 -1
- package/dist/{local-d1-Bg9OzEEO.mjs → local-d1-2CMnpuW_.mjs} +2 -2
- package/dist/login-DYt_An22.mjs +2 -0
- package/dist/{login-CAsAsQ-_.mjs → login-UZKFM_u7.mjs} +3 -3
- package/dist/{logs-BjKvFnVM.mjs → logs-CUZ6t9t3.mjs} +3 -3
- package/dist/migrate-8_2u55MD.mjs +2 -0
- package/dist/{migrate-BPITvDJN.mjs → migrate-DHul7PRV.mjs} +2 -1
- package/dist/{node-Dt7z256D.mjs → node-BkyRWRx8.mjs} +1 -1
- package/dist/operator-args-CLgKGlwU.mjs +690 -0
- package/dist/{operator-cmd-BK5CCiT9.mjs → operator-cmd-DBA6dl0m.mjs} +68 -22
- package/dist/pages/client.d.mts +34 -2
- package/dist/pages/client.mjs +59 -3
- package/dist/pages/index.d.mts +1 -1
- package/dist/pages/index.mjs +1 -1
- package/dist/pages/islands-plugin.mjs +1 -1
- package/dist/pages/protocol.d.mts +2 -2
- package/dist/pages/protocol.mjs +2 -308
- package/dist/{parse-filename-DioPHiR9.mjs → parse-filename-CUbj-1MP.mjs} +35 -1
- package/dist/plan-D1Q5rf-r.mjs +2 -0
- package/dist/plan-NPpwZ_kc.mjs +58 -0
- package/dist/platform-args-BJdRtlLq.mjs +506 -0
- package/dist/platform-args-D3RXyR6h.mjs +2 -0
- package/dist/{platform-auth-config-BlN8xTdD.mjs → platform-auth-config-B56E9YP1.mjs} +3 -3
- package/dist/{platform-auth-protection-7d5aV2Jg.mjs → platform-auth-protection-BDWO_aER.mjs} +2 -2
- package/dist/{platform-auth-recovery-Dxij8ZbR.mjs → platform-auth-recovery-1gg4CSRe.mjs} +3 -3
- package/dist/{platform-cmd-E0FuL212.mjs → platform-cmd-Bt-1w6pY.mjs} +1 -1
- package/dist/{platform-cmd-B3hwKrFK.mjs → platform-cmd-DMcQStSc.mjs} +24 -3
- package/dist/{platform-domain-D6Xcy9ZX.mjs → platform-domain-BNkcz0OB.mjs} +2 -2
- package/dist/{platform-lifecycle-k0E0xoxx.mjs → platform-lifecycle-9OyBALhH.mjs} +327 -215
- package/dist/{platform-lifecycle-DMh_qrry.mjs → platform-lifecycle-BE6C_jxh.mjs} +1 -1
- package/dist/{platform-management-Brz_BDiT.mjs → platform-management-CjwLVQwN.mjs} +6 -3
- package/dist/{platform-management-DOtss0BN.mjs → platform-management-CnyTdcWX.mjs} +1 -1
- package/dist/platform-plans-config-BNGKGr4P.mjs +359 -0
- package/dist/{platform-recovery-BvtcXON5.mjs → platform-recovery-D6KSpuFm.mjs} +2 -2
- package/dist/{plugin-inference-BMfKRSqE.mjs → plugin-inference-CXWnn79A.mjs} +174 -64
- package/dist/{prepare-C-6YZyyg.mjs → prepare-B5Mkic5u.mjs} +1 -1
- package/dist/{prepare-CRhJbVrG.mjs → prepare-DOsL0CC9.mjs} +4 -20
- package/dist/prepare-cgvDMtSb.mjs +2 -0
- package/dist/{project-cmd-BZLCqOqw.mjs → project-cmd-CNzrqvBv.mjs} +16 -16
- package/dist/{project-team-BvgM0WoX.mjs → project-team-DQOWPfQT.mjs} +2 -2
- package/dist/{project-token-l5DqK6Az.mjs → project-token-CTDYU0Cc.mjs} +2 -2
- package/dist/{project-zero-trust-v6Mvpp8y.mjs → project-zero-trust-BNAkW-_0.mjs} +2 -2
- package/dist/{protocol-BBa6cstI.d.mts → protocol-CjF_iI9X.d.mts} +2 -2
- package/dist/protocol-U7bfjHmA.mjs +331 -0
- package/dist/{provision-Fr9pRqce.mjs → provision-C4ORE7G7.mjs} +1 -1
- package/dist/{provision-C4IGqkBf.mjs → provision-CJFgTZY8.mjs} +89 -198
- package/dist/{requests-DN-BbNiM.mjs → requests-MhxYnau8.mjs} +2 -2
- package/dist/resource-name-C7LVpcRm.mjs +11 -0
- package/dist/{rollback-D7rzSaZM.mjs → rollback-CJ6iSDoU.mjs} +3 -3
- package/dist/route-url-CG7U-cRN.mjs +15 -0
- package/dist/{runner-B8wXwWlo.mjs → runner-CXA9Fh8h.mjs} +1 -1
- package/dist/{runner-p-dMs2UN.mjs → runner-Ol0TNjk6.mjs} +2 -2
- package/dist/runtime/ai.d.mts +12 -8
- package/dist/runtime/ai.mjs +84 -17
- package/dist/runtime/better-auth-mysql.mjs +1 -1
- package/dist/runtime/better-auth-pg.mjs +1 -1
- package/dist/runtime/better-auth.mjs +1 -1
- package/dist/runtime/client-react.mjs +2 -2
- package/dist/runtime/client-solid.mjs +2 -2
- package/dist/runtime/client-svelte.mjs +2 -2
- package/dist/runtime/client-vue.mjs +2 -2
- package/dist/runtime/client.mjs +2 -2
- package/dist/runtime/durable.d.mts +3 -1
- package/dist/runtime/durable.mjs +4 -1
- package/dist/runtime/email/testing.mjs +1 -1
- package/dist/runtime/env-public.d.mts +1 -1
- package/dist/runtime/fetch-stream.mjs +1 -1
- package/dist/runtime/fetch.mjs +1 -1
- package/dist/runtime/handler.d.mts +1 -1
- package/dist/runtime/kv.mjs +0 -1
- package/dist/runtime/limits.d.mts +2 -0
- package/dist/runtime/limits.mjs +2 -0
- package/dist/runtime/live-client.d.mts +1 -1
- package/dist/runtime/live-server.mjs +25 -16
- package/dist/runtime/live.d.mts +1 -1
- package/dist/runtime/migration-handler.mjs +62 -42
- package/dist/runtime/route-url.d.mts +4 -0
- package/dist/runtime/route-url.mjs +2 -0
- package/dist/runtime/routing.d.mts +180 -0
- package/dist/runtime/routing.mjs +1082 -0
- package/dist/runtime/sandbox-container.d.mts +1 -1
- package/dist/runtime/sandbox-container.mjs +1 -1
- package/dist/runtime/sandbox.d.mts +3 -3
- package/dist/runtime/sandbox.mjs +75 -45
- package/dist/runtime/sse.mjs +1 -1
- package/dist/runtime/validator.d.mts +1 -1
- package/dist/runtime/ws-server.d.mts +4 -2
- package/dist/runtime/ws-server.mjs +27 -2
- package/dist/runtime/ws.d.mts +2 -2
- package/dist/runtime/ws.mjs +8 -6
- package/dist/{sandbox-qpNBT8a3.d.mts → sandbox-XZAqzFlG.d.mts} +11 -8
- package/dist/{sandbox-container-DdNEBfCc.d.mts → sandbox-container-Bo0eiFKz.d.mts} +2 -1
- package/dist/{sandbox-container-4fdqLnyb.mjs → sandbox-container-C6ItmVuN.mjs} +4 -2
- package/dist/{scan-4tfN-PSn.mjs → scan-C7okrLyM.mjs} +4 -35
- package/dist/{secret-BOtOl_cb.mjs → secret-Dli5fP0B.mjs} +4 -4
- package/dist/{sse-BaC1jXko.mjs → sse-CQNaDFFV.mjs} +6 -3
- package/dist/validate-Dq_L3s0S.mjs +2 -0
- package/dist/{validate-CIUwFpjB.mjs → validate-ctOrgiS3.mjs} +2 -1
- package/dist/{wrangler-DQF1vKyf.mjs → wrangler-7K-bW_DL.mjs} +8 -239
- package/dist/{ws-BoY7vQML.d.mts → ws-CL1w7GXU.d.mts} +13 -2
- package/package.json +15 -8
- package/skills/migrate-vite-cloudflare-to-void/SKILL.md +34 -157
- package/skills/void/SKILL.md +50 -135
- package/skills/void/docs/guide/ai.md +94 -84
- package/skills/void/docs/guide/app-types.md +3 -32
- package/skills/void/docs/guide/auth.md +12 -116
- package/skills/void/docs/guide/database/d1.md +9 -54
- package/skills/void/docs/guide/database/mysql.md +1 -1
- package/skills/void/docs/guide/database/postgresql.md +5 -26
- package/skills/void/docs/guide/database.md +23 -75
- package/skills/void/docs/guide/deployment.md +27 -113
- package/skills/void/docs/guide/durable-state.md +43 -18
- package/skills/void/docs/guide/edge/headers.md +3 -47
- package/skills/void/docs/guide/edge/prerendering.md +5 -20
- package/skills/void/docs/guide/edge/redirects.md +11 -64
- package/skills/void/docs/guide/edge/revalidation.md +5 -18
- package/skills/void/docs/guide/edge/rewrites.md +56 -284
- package/skills/void/docs/guide/edge/static-assets.md +22 -72
- package/skills/void/docs/guide/email/domains.md +112 -0
- package/skills/void/docs/guide/email/receiving.md +139 -0
- package/skills/void/docs/guide/email/sending.md +231 -0
- package/skills/void/docs/guide/email.md +13 -619
- package/skills/void/docs/guide/env-migration.md +11 -11
- package/skills/void/docs/guide/env-vars.md +9 -29
- package/skills/void/docs/guide/index.md +0 -15
- package/skills/void/docs/guide/jobs.md +3 -18
- package/skills/void/docs/guide/kv.md +5 -11
- package/skills/void/docs/guide/live.md +5 -56
- package/skills/void/docs/guide/pages-routing/actions-and-forms.md +78 -125
- package/skills/void/docs/guide/pages-routing/head.md +10 -10
- package/skills/void/docs/guide/pages-routing/islands.md +6 -36
- package/skills/void/docs/guide/pages-routing/layouts.md +6 -128
- package/skills/void/docs/guide/pages-routing/loaders.md +3 -19
- package/skills/void/docs/guide/pages-routing/markdown.md +13 -171
- package/skills/void/docs/guide/pages-routing/overview.md +7 -17
- package/skills/void/docs/guide/pages-routing/view-transitions.md +1 -1
- package/skills/void/docs/guide/platform/administration/access.md +1 -4
- package/skills/void/docs/guide/platform/administration/email.md +35 -8
- package/skills/void/docs/guide/platform/administration/operations.md +26 -4
- package/skills/void/docs/guide/platform/administration/plans.md +126 -0
- package/skills/void/docs/guide/platform/administration/projects.md +5 -2
- package/skills/void/docs/guide/platform/administration/zero-trust.md +23 -152
- package/skills/void/docs/guide/platform/development/runtime.md +3 -13
- package/skills/void/docs/guide/platform/development/schema-ci.md +0 -58
- package/skills/void/docs/guide/platform/installation/credentials.md +6 -4
- package/skills/void/docs/guide/platform/installation/domains.md +30 -2
- package/skills/void/docs/guide/platform/installation/first-deployment.md +2 -0
- package/skills/void/docs/guide/platform/installation/maintenance.md +3 -1
- package/skills/void/docs/guide/platform/installation/prerequisites.md +20 -15
- package/skills/void/docs/guide/platform/installation/setup.md +9 -5
- package/skills/void/docs/guide/platform-administration.md +1 -0
- package/skills/void/docs/guide/queues.md +7 -9
- package/skills/void/docs/guide/quickstart.md +38 -37
- package/skills/void/docs/guide/remote-dev.md +4 -9
- package/skills/void/docs/guide/sandboxes.md +29 -21
- package/skills/void/docs/guide/server-routing.md +9 -72
- package/skills/void/docs/guide/sse.md +4 -18
- package/skills/void/docs/guide/ssg.md +3 -15
- package/skills/void/docs/guide/ssr.md +14 -62
- package/skills/void/docs/guide/storage.md +9 -4
- package/skills/void/docs/guide/type-safety.md +3 -14
- package/skills/void/docs/guide/typed-fetch.md +3 -7
- package/skills/void/docs/guide/websockets.md +68 -40
- package/skills/void/docs/integrations/agents.md +3 -3
- package/skills/void/docs/integrations/cloudflare.md +85 -316
- package/skills/void/docs/integrations/frameworks/analog.md +5 -64
- package/skills/void/docs/integrations/frameworks/astro.md +4 -73
- package/skills/void/docs/integrations/frameworks/nuxt.md +5 -62
- package/skills/void/docs/integrations/frameworks/overview.md +11 -54
- package/skills/void/docs/integrations/frameworks/react-router.md +5 -60
- package/skills/void/docs/integrations/frameworks/sveltekit.md +6 -65
- package/skills/void/docs/integrations/frameworks/tanstack-start.md +4 -62
- package/skills/void/docs/integrations/nodejs-bun-deno.md +5 -69
- package/skills/void/docs/reference/api/auth.md +156 -0
- package/skills/void/docs/reference/api/client.md +87 -0
- package/skills/void/docs/reference/api/database.md +95 -0
- package/skills/void/docs/reference/api/durable.md +46 -0
- package/skills/void/docs/reference/api/env.md +50 -0
- package/skills/void/docs/reference/api/handlers.md +254 -0
- package/skills/void/docs/reference/api/pages.md +241 -0
- package/skills/void/docs/reference/api/plugin.md +39 -0
- package/skills/void/docs/reference/api/resources.md +109 -0
- package/skills/void/docs/reference/api/rewrites.md +76 -0
- package/skills/void/docs/reference/api/types.md +92 -0
- package/skills/void/docs/reference/api.md +56 -1218
- package/skills/void/docs/reference/cli/auth.md +88 -0
- package/skills/void/docs/reference/cli/database.md +128 -0
- package/skills/void/docs/reference/cli/deploy.md +85 -0
- package/skills/void/docs/reference/cli/domains.md +41 -0
- package/skills/void/docs/reference/cli/email.md +129 -0
- package/skills/void/docs/reference/cli/generate.md +116 -0
- package/skills/void/docs/reference/cli/github.md +189 -0
- package/skills/void/docs/reference/cli/platform-config.md +92 -0
- package/skills/void/docs/reference/cli/platform-email.md +81 -0
- package/skills/void/docs/reference/cli/platform-installation.md +127 -0
- package/skills/void/docs/reference/cli/platform-operations.md +90 -0
- package/skills/void/docs/reference/cli/platform-users.md +89 -0
- package/skills/void/docs/reference/cli/platform-zero-trust.md +45 -0
- package/skills/void/docs/reference/cli/platform.md +70 -0
- package/skills/void/docs/reference/cli/project.md +214 -0
- package/skills/void/docs/reference/cli/secrets.md +76 -0
- package/skills/void/docs/reference/cli/setup.md +70 -0
- package/skills/void/docs/reference/cli.md +32 -1682
- package/skills/void/docs/reference/config.md +12 -18
- package/skills/void/docs/reference/resource-inference.md +3 -58
- package/skills/void/docs/reference/structure.md +14 -41
- package/dist/canonical-json-DuDiiUsQ.mjs +0 -13
- package/dist/client-Czz8o5jP.mjs +0 -2
- package/dist/gen-CNJ62MM7.mjs +0 -2
- package/dist/help-CmZzxUba.mjs +0 -2
- package/dist/login-CGcRKEoi.mjs +0 -2
- package/dist/migrate-CYfbKkXh.mjs +0 -2
- package/dist/plan-BEZ8VJW0.mjs +0 -256
- package/dist/plan-DpuOr14e.mjs +0 -2
- package/dist/prepare-Bm3iq-u4.mjs +0 -2
- package/dist/validate-EKmJWxmy.mjs +0 -2
- /package/dist/cli/{cf-compat.d.mts → cloudflare-operation-process.d.mts} +0 -0
|
@@ -2,1230 +2,68 @@
|
|
|
2
2
|
outline: deep
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<script setup>
|
|
6
|
+
import LegacyDocRedirect from "../.vitepress/theme/LegacyDocRedirect.vue";
|
|
7
|
+
import links from "../.vitepress/redirects/reference-api.json";
|
|
8
|
+
</script>
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
<LegacyDocRedirect page="reference/api.md" :links="links" />
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
# API Reference {#api-reference}
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
Use this reference to find public imports, signatures, and return types. For setup and examples, start with the [guides](../guide/index.md).
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
## API Topics
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
| Topic | Use it for |
|
|
19
|
+
| -------------------------------------------------- | --------------------------------------------------------------- |
|
|
20
|
+
| [Plugin and configuration](./api/plugin.md) | Add Void to Vite and configure your app. |
|
|
21
|
+
| [Handlers and middleware](./api/handlers.md) | HTTP routes, validation, scheduled jobs, queues, and rendering. |
|
|
22
|
+
| [Rewrites](./api/rewrites.md) | Serve another route while keeping the requested URL. |
|
|
23
|
+
| [Authentication](./api/auth.md) | Sessions, users, and the auth client. |
|
|
24
|
+
| [Fetch client](./api/client.md) | Typed requests and errors. |
|
|
25
|
+
| [Durable State and WebSockets](./api/durable.md) | Persistent objects and typed connections. |
|
|
26
|
+
| [Database and seeding](./api/database.md) | Queries, operators, and seed scripts. |
|
|
27
|
+
| [KV, storage, AI, and logging](./api/resources.md) | Resource clients, cache revalidation, and logs. |
|
|
28
|
+
| [Types](./api/types.md) | Handler context, route types, and head metadata. |
|
|
29
|
+
| [Environment variables](./api/env.md) | Validated environment values and binding types. |
|
|
30
|
+
| [Pages adapters](./api/pages.md) | React, Vue, Svelte, Solid, and Markdown. |
|
|
17
31
|
|
|
18
|
-
|
|
19
|
-
plugins: [voidPlugin()],
|
|
20
|
-
});
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
| Option | Type | Description |
|
|
24
|
-
| ------------------ | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
25
|
-
| `persistTo` | `string` | Directory path for persisting local dev state (D1, KV, R2). Defaults to `.void/` in the project root. |
|
|
26
|
-
| `auxiliaryWorkers` | `AuxiliaryWorkerConfig[]` | Additional workers to run inside the same Miniflare instance during dev. Passed through to `@cloudflare/vite-plugin`. Useful for running multiple workers that share bindings (e.g. a separate API worker alongside a dashboard). |
|
|
27
|
-
|
|
28
|
-
## Project configuration
|
|
29
|
-
|
|
30
|
-
### `defineConfig(config)`
|
|
31
|
-
|
|
32
|
-
Import from `void/config` in the root `void.config.ts`. It returns the config with editor completion and TypeScript checking. Void validates the result when loading it, including values computed at runtime.
|
|
33
|
-
|
|
34
|
-
```ts
|
|
35
|
-
import { defineConfig } from 'void/config';
|
|
36
|
-
|
|
37
|
-
export default defineConfig({
|
|
38
|
-
cloudflare: { name: 'my-app' },
|
|
39
|
-
routing: { revalidate: 60 },
|
|
40
|
-
});
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
See the [config reference](./config.md) for all fields.
|
|
44
|
-
|
|
45
|
-
## Handlers
|
|
46
|
-
|
|
47
|
-
Imported from `"void"` or `"void/handler"`.
|
|
48
|
-
|
|
49
|
-
### `defineHandler(handler)`
|
|
50
|
-
|
|
51
|
-
Wraps a route handler function. The handler receives a [`CloudContext`](#cloudcontext) and can return a plain value (auto-converted to a Response) or use the Hono `c.json()` / `c.text()` APIs directly.
|
|
52
|
-
|
|
53
|
-
```ts
|
|
54
|
-
import { defineHandler } from 'void';
|
|
55
|
-
|
|
56
|
-
export const GET = defineHandler((c) => {
|
|
57
|
-
return { message: 'hello' };
|
|
58
|
-
});
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
**Signature:**
|
|
62
|
-
|
|
63
|
-
```ts
|
|
64
|
-
function defineHandler<R>(handler: (c: CloudContext) => R): TypedHandler<{}, R>;
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### `defineHandler(middleware..., handler)`
|
|
68
|
-
|
|
69
|
-
Composes up to 5 per-route middleware with a final handler. Middleware runs in order before the handler.
|
|
70
|
-
|
|
71
|
-
```ts
|
|
72
|
-
export const GET = defineHandler(authMiddleware, rateLimiter, (c) => {
|
|
73
|
-
return { ok: true };
|
|
74
|
-
});
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### `defineHandler.withValidator(validators)`
|
|
78
|
-
|
|
79
|
-
Creates a handler with input validation using any [Standard Schema](https://github.com/standard-schema/standard-schema) compatible library (zod, valibot, arktype, etc.). Returns a curried function that accepts the handler.
|
|
80
|
-
|
|
81
|
-
Validated input is passed as the second argument to the handler.
|
|
82
|
-
|
|
83
|
-
```ts
|
|
84
|
-
import { defineHandler } from 'void';
|
|
85
|
-
import * as v from 'valibot';
|
|
86
|
-
|
|
87
|
-
export const POST = defineHandler.withValidator({
|
|
88
|
-
body: v.object({
|
|
89
|
-
name: v.pipe(v.string(), v.minLength(1)),
|
|
90
|
-
email: v.pipe(v.string(), v.email()),
|
|
91
|
-
}),
|
|
92
|
-
})((c, { body }) => {
|
|
93
|
-
return { received: body.name };
|
|
94
|
-
});
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
**Signature:**
|
|
98
|
-
|
|
99
|
-
```ts
|
|
100
|
-
function withValidator<V extends ValidatorSlots>(
|
|
101
|
-
validators: V,
|
|
102
|
-
): <R>(handler: (c: CloudContext, input: HandlerInput<V>) => R) => TypedHandler<V, R>;
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
**Type: `ValidatorSlots`**
|
|
106
|
-
|
|
107
|
-
```ts
|
|
108
|
-
interface ValidatorSlots {
|
|
109
|
-
body?: StandardSchemaV1;
|
|
110
|
-
query?: StandardSchemaV1;
|
|
111
|
-
params?: StandardSchemaV1;
|
|
112
|
-
}
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
**Type: `HandlerInput<V>`**
|
|
116
|
-
|
|
117
|
-
The inferred output types of each validator slot. For a `ValidatorSlots` with `body` and `query`, the input object has `{ body: ..., query: ... }` with types inferred from the schema output.
|
|
118
|
-
|
|
119
|
-
### `defineMiddleware(handler)`
|
|
120
|
-
|
|
121
|
-
Type-safe wrapper for Hono middleware. At runtime, returns the function unchanged.
|
|
122
|
-
|
|
123
|
-
```ts
|
|
124
|
-
import { defineMiddleware } from 'void';
|
|
125
|
-
|
|
126
|
-
export default defineMiddleware(async (c, next) => {
|
|
127
|
-
console.log(`${c.req.method} ${c.req.path}`);
|
|
128
|
-
await next();
|
|
129
|
-
});
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
**Signature:**
|
|
133
|
-
|
|
134
|
-
```ts
|
|
135
|
-
function defineMiddleware(handler: MiddlewareHandler<CloudEnv>): MiddlewareHandler<CloudEnv>;
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### `basicAuth(options)`
|
|
139
|
-
|
|
140
|
-
Built-in Basic authentication middleware for temporary site gates and pre-launch protection. Use it from `middleware/` with credentials from `void/env` to protect the whole app, or pass it to `defineHandler()` for a single route.
|
|
141
|
-
|
|
142
|
-
Void internal endpoints under `/__void` are always excluded so deploy-time migrations, prerendering, cron/queue dispatch, and remote binding helpers still reach Void's own internal-token checks.
|
|
143
|
-
|
|
144
|
-
When credentials come from `void/env`, wrap the reads in functions so they are resolved per request after Void has bound the runtime env.
|
|
145
|
-
|
|
146
|
-
For app-specific bypasses such as health checks or public webhooks, compose that logic in your own middleware before calling `basicAuth()`.
|
|
147
|
-
|
|
148
|
-
```ts
|
|
149
|
-
// env.ts
|
|
150
|
-
import { defineEnv, string } from 'void/env';
|
|
151
|
-
|
|
152
|
-
export default defineEnv({
|
|
153
|
-
BASIC_AUTH_USERNAME: string(),
|
|
154
|
-
BASIC_AUTH_PASSWORD: string(),
|
|
155
|
-
});
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
```ts
|
|
159
|
-
// middleware/01.basic-auth.ts
|
|
160
|
-
import { basicAuth } from 'void';
|
|
161
|
-
import { env } from 'void/env';
|
|
162
|
-
|
|
163
|
-
export default basicAuth({
|
|
164
|
-
username: () => env.BASIC_AUTH_USERNAME,
|
|
165
|
-
password: () => env.BASIC_AUTH_PASSWORD,
|
|
166
|
-
realm: 'Preview',
|
|
167
|
-
});
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
**Signature:**
|
|
171
|
-
|
|
172
|
-
```ts
|
|
173
|
-
function basicAuth(options: {
|
|
174
|
-
username: string | (() => string);
|
|
175
|
-
password: string | (() => string);
|
|
176
|
-
realm?: string | (() => string);
|
|
177
|
-
message?: string | (() => string);
|
|
178
|
-
}): MiddlewareHandler<CloudEnv>;
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### `defineScheduled(handler)`
|
|
182
|
-
|
|
183
|
-
Wraps a Cloudflare [Scheduled handler](https://developers.cloudflare.com/workers/runtime-apis/handlers/scheduled/) with type inference.
|
|
184
|
-
|
|
185
|
-
```ts
|
|
186
|
-
import { defineScheduled } from 'void';
|
|
187
|
-
|
|
188
|
-
export default defineScheduled(async (controller, env, ctx) => {
|
|
189
|
-
const { results } = await env.DB.prepare('SELECT * FROM stale').all();
|
|
190
|
-
// ...
|
|
191
|
-
});
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
**Signature:**
|
|
195
|
-
|
|
196
|
-
```ts
|
|
197
|
-
function defineScheduled(
|
|
198
|
-
handler: (
|
|
199
|
-
controller: ScheduledController,
|
|
200
|
-
env: CloudEnv['Bindings'],
|
|
201
|
-
ctx: ExecutionContext,
|
|
202
|
-
) => unknown | Promise<unknown>,
|
|
203
|
-
): ScheduledFn;
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
### `defineQueue<T>(handler)`
|
|
207
|
-
|
|
208
|
-
Wraps a [queue](../guide/queues.md) consumer handler with typed message bodies. The generic `<T>` defines the message body type, which flows through to the typed `queues` proxy for `send()` calls.
|
|
209
|
-
|
|
210
|
-
```ts
|
|
211
|
-
import { defineQueue } from 'void';
|
|
212
|
-
|
|
213
|
-
export default defineQueue<{ to: string; subject: string }>(async (batch, env) => {
|
|
214
|
-
for (const msg of batch.messages) {
|
|
215
|
-
console.log(`Send to ${msg.body.to}: ${msg.body.subject}`);
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
**Signature:**
|
|
221
|
-
|
|
222
|
-
```ts
|
|
223
|
-
function defineQueue<T>(
|
|
224
|
-
handler: (batch: QueueBatch<T>, env: CloudEnv['Bindings']) => void | Promise<void>,
|
|
225
|
-
): QueueFn;
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
### `defineRender(handler)`
|
|
229
|
-
|
|
230
|
-
Wraps an SSR render entry. The second argument provides pre-built `<head>` and `<body>` asset tags for injecting client scripts and styles.
|
|
231
|
-
|
|
232
|
-
```ts
|
|
233
|
-
import { defineRender } from "void";
|
|
234
|
-
import { renderToString } from "react-dom/server";
|
|
235
|
-
|
|
236
|
-
export default defineRender((c, assetTags) => {
|
|
237
|
-
const html = renderToString(<App />);
|
|
238
|
-
return c.html(`<!DOCTYPE html>
|
|
239
|
-
<html><head>${assetTags.css}${assetTags.preloads}</head>
|
|
240
|
-
<body><div id="root">${html}</div>${assetTags.body}</body></html>`);
|
|
241
|
-
});
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
**Signature:**
|
|
245
|
-
|
|
246
|
-
```ts
|
|
247
|
-
function defineRender(
|
|
248
|
-
handler: (c: CloudContext, assetTags: RenderAssetTags) => Response | Promise<Response>,
|
|
249
|
-
): RenderFn;
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
**Type: `RenderAssetTags`**
|
|
253
|
-
|
|
254
|
-
```ts
|
|
255
|
-
interface RenderAssetTags {
|
|
256
|
-
css: string; // Stylesheet links for <head>
|
|
257
|
-
preloads: string; // Modulepreload and dev client tags for <head>
|
|
258
|
-
body: string; // Script tags for before </body>
|
|
259
|
-
}
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
### `defineHead<P>(handler)`
|
|
263
|
-
|
|
264
|
-
Type-safe wrapper for the page `head()` export in `.server.ts` files. Provides [`CloudContext`](#cloudcontext) typing for the first argument and generic props typing for the second.
|
|
265
|
-
|
|
266
|
-
```ts
|
|
267
|
-
import { defineHandler, defineHead } from 'void';
|
|
268
|
-
import type { InferProps } from 'void';
|
|
269
|
-
|
|
270
|
-
export type Props = InferProps<typeof loader>;
|
|
271
|
-
|
|
272
|
-
export const loader = defineHandler(async (c) => {
|
|
273
|
-
const post = await getPost(c.req.param('slug'));
|
|
274
|
-
return { post };
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
export const head = defineHead<Props>((c, props) => {
|
|
278
|
-
return {
|
|
279
|
-
title: props.post.title,
|
|
280
|
-
meta: [
|
|
281
|
-
{ name: 'description', content: props.post.excerpt },
|
|
282
|
-
{ property: 'og:title', content: props.post.title },
|
|
283
|
-
],
|
|
284
|
-
};
|
|
285
|
-
});
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
**Signature:**
|
|
289
|
-
|
|
290
|
-
```ts
|
|
291
|
-
function defineHead<P = Record<string, unknown>>(
|
|
292
|
-
handler: (c: CloudContext, props: P) => HeadDescriptor | undefined,
|
|
293
|
-
): (c: CloudContext, props: P) => HeadDescriptor | undefined;
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
## Rewrites
|
|
297
|
-
|
|
298
|
-
URL rewrites re-dispatch a request at a different internal path without changing the browser's URL. `c.rewrite()`, `c.originalUrl()`, and `c.isRewritten()` are available on every Hono `Context` the Void runtime hands you. See the [Rewrites guide](../guide/edge/rewrites.md) for the full overview, including static `routing.rewrites` / `routing.fallbacks` in [`void.config.ts`](./config.md#routing).
|
|
299
|
-
|
|
300
|
-
### `c.rewrite(destination)`
|
|
301
|
-
|
|
302
|
-
Re-dispatches the current request at `destination` and returns the resulting `Response`. The browser URL does not change — this is a server-side hop. If `destination` has no query string, the original request query is preserved. If `destination` includes a query string, it replaces the original query. `destination` must start with `/`; known generated routes autocomplete via [`RewriteDestination`](#rewritedestination), while arbitrary strings remain accepted for dynamic paths.
|
|
303
|
-
|
|
304
|
-
`c.redirect()` also preserves request query params for internal destinations, but it merges rather than replaces: destination params win on collision, and request-only params are appended.
|
|
305
|
-
|
|
306
|
-
```ts
|
|
307
|
-
import { defineHandler } from 'void';
|
|
308
|
-
|
|
309
|
-
export const GET = defineHandler((c) => {
|
|
310
|
-
const locale = c.req.header('accept-language')?.startsWith('de') ? 'de' : 'en';
|
|
311
|
-
return c.rewrite(`/${locale}${new URL(c.req.url).pathname}`);
|
|
312
|
-
});
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
**Signature:**
|
|
316
|
-
|
|
317
|
-
```ts
|
|
318
|
-
interface CloudContext {
|
|
319
|
-
rewrite(destination: RewriteDestination): Promise<Response>;
|
|
320
|
-
}
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
**Caveats:**
|
|
324
|
-
|
|
325
|
-
- `destination` must start with a single `/` and point at an internal path. External URLs, protocol-relative destinations (`//host/...`), and anything non-path-absolute throw immediately — use `fetch()` for cross-origin calls.
|
|
326
|
-
- Destinations whose final path segment ends in a known static-asset extension (e.g. `/hero.png`, `/app.css`, `/data.json`) throw `VoidAssetRewriteError` (exported from `"void"`) before the re-dispatch. Runtime rewrites cannot reach assets — use a static `routing.rewrites` rule or a `_redirects` `200!` entry. `.html` is deliberately excluded from this guard because `.html` paths may be legitimate route handlers. See the [guide](../guide/edge/rewrites.md#runtime-rewrites-cannot-reach-static-assets) for the full extension list and rationale.
|
|
327
|
-
- Middleware re-runs on every rewrite hop. Guard side-effects with [`c.isRewritten()`](#c-originalurl-c-isrewritten).
|
|
328
|
-
- Client-side SPA navigation via `Link` does not trigger server rewrites; only full HTTP requests do.
|
|
329
|
-
- [ISR](../guide/edge/revalidation.md) cache keys follow the rewritten path, not the original URL.
|
|
330
|
-
|
|
331
|
-
### `c.originalUrl()` / `c.isRewritten()`
|
|
332
|
-
|
|
333
|
-
Context methods for inspecting rewrite state. `c.originalUrl()` returns the pre-rewrite URL as a `URL` object, or `null` on the first, non-rewritten hop. `c.isRewritten()` returns `true` on any re-dispatched context and `false` on the original. Both helpers read from an in-worker `WeakMap<Request, URL>` keyed on `c.req.raw`; the `X-Void-Original-URL` header is only how edge dispatch forwards the pre-rewrite URL to the worker, and entry middleware migrates it into the map once per request.
|
|
334
|
-
|
|
335
|
-
```ts
|
|
336
|
-
import { defineMiddleware } from 'void';
|
|
337
|
-
|
|
338
|
-
export default defineMiddleware(async (c, next) => {
|
|
339
|
-
if (!c.isRewritten()) {
|
|
340
|
-
// Only log the user-visible request, not internal rewrite hops.
|
|
341
|
-
console.log(`${c.req.method} ${c.req.path}`);
|
|
342
|
-
}
|
|
343
|
-
await next();
|
|
344
|
-
});
|
|
345
|
-
```
|
|
346
|
-
|
|
347
|
-
**Signature:**
|
|
348
|
-
|
|
349
|
-
```ts
|
|
350
|
-
interface CloudContext {
|
|
351
|
-
originalUrl(): URL | null;
|
|
352
|
-
isRewritten(): boolean;
|
|
353
|
-
}
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
### `RewriteDestination`
|
|
357
|
-
|
|
358
|
-
```ts
|
|
359
|
-
import type { RewriteDestination } from 'void/routes';
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
Union of the exact route patterns from your generated `RouteMap` plus a `string` fallback (`RouteName | (string & {})`). Known route patterns (e.g. `/posts/[id]`) are offered as autocomplete entries in your editor, while the `string` branch keeps the type assignable from concrete runtime paths like `` `/posts/${id}` `` — there is no `:id` template-literal resolution at the type level. Used as:
|
|
363
|
-
|
|
364
|
-
- The parameter type of [`c.rewrite()`](#c-rewrite-destination).
|
|
365
|
-
- The type of `destination` entries in `routing.rewrites` and `routing.fallbacks` in [`void.config.ts`](./config.md#routing).
|
|
366
|
-
|
|
367
|
-
Like [`RouteMap`](#routemap), `RewriteDestination` lives in the virtual `void/routes` module and is refreshed whenever routes change.
|
|
368
|
-
|
|
369
|
-
## Auth
|
|
370
|
-
|
|
371
|
-
Imported from `"void"` or `"void/auth"`. Client-side helpers imported from `"void/client"`.
|
|
372
|
-
|
|
373
|
-
### `defineAuth(config)`
|
|
374
|
-
|
|
375
|
-
Advanced escape hatch for customizing Void's Better Auth config.
|
|
376
|
-
|
|
377
|
-
```ts
|
|
378
|
-
import { defineAuth } from 'void/auth';
|
|
379
|
-
|
|
380
|
-
export default defineAuth(({ defaults }) => ({
|
|
381
|
-
...defaults,
|
|
382
|
-
trustedOrigins: ['https://example.com'],
|
|
383
|
-
}));
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
**Signature:**
|
|
387
|
-
|
|
388
|
-
```ts
|
|
389
|
-
function defineAuth(config: VoidAuthConfig): VoidAuthConfig;
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
### `getUser()`
|
|
393
|
-
|
|
394
|
-
Returns the current authenticated user from AsyncLocalStorage, or `null` when no user is present.
|
|
395
|
-
|
|
396
|
-
```ts
|
|
397
|
-
import { getUser } from 'void/auth';
|
|
398
|
-
|
|
399
|
-
const user = getUser();
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
**Signature:**
|
|
403
|
-
|
|
404
|
-
```ts
|
|
405
|
-
function getUser(): AuthUser | null;
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
### `getSession()`
|
|
409
|
-
|
|
410
|
-
Returns the current Better Auth request state, or `null`.
|
|
411
|
-
|
|
412
|
-
```ts
|
|
413
|
-
import { getSession } from 'void/auth';
|
|
414
|
-
|
|
415
|
-
const state = getSession();
|
|
416
|
-
```
|
|
417
|
-
|
|
418
|
-
**Signature:**
|
|
419
|
-
|
|
420
|
-
```ts
|
|
421
|
-
function getSession(): AuthState | null;
|
|
422
|
-
```
|
|
423
|
-
|
|
424
|
-
### `requireAuth(c)`
|
|
425
|
-
|
|
426
|
-
Extracts the authenticated user from the request context. Throws a 401 `HTTPException` if no session is present.
|
|
427
|
-
|
|
428
|
-
```ts
|
|
429
|
-
import { defineHandler } from 'void';
|
|
430
|
-
import { requireAuth } from 'void/auth';
|
|
431
|
-
|
|
432
|
-
export const GET = defineHandler((c) => {
|
|
433
|
-
const user = requireAuth(c);
|
|
434
|
-
return { email: user.email };
|
|
435
|
-
});
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
**Signature:**
|
|
439
|
-
|
|
440
|
-
```ts
|
|
441
|
-
function requireAuth(c: CloudContext): AuthUser;
|
|
442
|
-
```
|
|
443
|
-
|
|
444
|
-
### `AuthUser`
|
|
445
|
-
|
|
446
|
-
Better Auth user shape re-exported by Void.
|
|
447
|
-
|
|
448
|
-
```ts
|
|
449
|
-
interface AuthUser {
|
|
450
|
-
id: string;
|
|
451
|
-
email: string;
|
|
452
|
-
emailVerified: boolean;
|
|
453
|
-
name: string;
|
|
454
|
-
image?: string | null;
|
|
455
|
-
createdAt: Date;
|
|
456
|
-
updatedAt: Date;
|
|
457
|
-
}
|
|
458
|
-
```
|
|
459
|
-
|
|
460
|
-
### `AuthSession`
|
|
461
|
-
|
|
462
|
-
Better Auth session shape re-exported by Void.
|
|
463
|
-
|
|
464
|
-
```ts
|
|
465
|
-
interface AuthSession {
|
|
466
|
-
id: string;
|
|
467
|
-
token: string;
|
|
468
|
-
userId: string;
|
|
469
|
-
expiresAt: Date;
|
|
470
|
-
createdAt: Date;
|
|
471
|
-
updatedAt: Date;
|
|
472
|
-
ipAddress?: string | null;
|
|
473
|
-
userAgent?: string | null;
|
|
474
|
-
}
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
### `AuthState`
|
|
478
|
-
|
|
479
|
-
Combined authenticated request state:
|
|
480
|
-
|
|
481
|
-
```ts
|
|
482
|
-
interface AuthState {
|
|
483
|
-
user: AuthUser;
|
|
484
|
-
session: AuthSession;
|
|
485
|
-
}
|
|
486
|
-
```
|
|
487
|
-
|
|
488
|
-
### `auth`
|
|
489
|
-
|
|
490
|
-
Imported from `"void/client"`. This is a ready-to-use Better Auth client instance preconfigured with `basePath: "/api/auth"`.
|
|
491
|
-
|
|
492
|
-
```ts
|
|
493
|
-
import { auth } from 'void/client';
|
|
494
|
-
|
|
495
|
-
await auth.signIn.email({ email, password });
|
|
496
|
-
await auth.signOut();
|
|
497
|
-
```
|
|
498
|
-
|
|
499
|
-
The exact client methods come from Better Auth. In pages apps, Void automatically chooses the framework-specific Better Auth client package when available.
|
|
500
|
-
|
|
501
|
-
For regular SPA apps that use Void for API/file routes without Void Pages mode, import the framework-specific client explicitly:
|
|
502
|
-
|
|
503
|
-
```ts
|
|
504
|
-
import { auth } from 'void/client/react';
|
|
505
|
-
// or: 'void/client/vue'
|
|
506
|
-
// or: 'void/client/svelte'
|
|
507
|
-
// or: 'void/client/solid'
|
|
508
|
-
```
|
|
509
|
-
|
|
510
|
-
Those subpaths keep the same `fetch`, `fetchStream`, and auth exports as `void/client`, but bind `auth` and `createAuthClient` to Better Auth's framework package.
|
|
511
|
-
|
|
512
|
-
### `createAuthClient`
|
|
513
|
-
|
|
514
|
-
Imported from `"void/client"`. Re-export of Better Auth's `createAuthClient` for advanced usage.
|
|
515
|
-
|
|
516
|
-
```ts
|
|
517
|
-
import { createAuthClient } from 'void/client';
|
|
518
|
-
|
|
519
|
-
const auth = createAuthClient({ basePath: '/api/auth' });
|
|
520
|
-
```
|
|
521
|
-
|
|
522
|
-
## Fetch Client
|
|
523
|
-
|
|
524
|
-
Imported from `"void/client"`.
|
|
525
|
-
|
|
526
|
-
### `fetch(path, options?)`
|
|
527
|
-
|
|
528
|
-
Type-safe fetch client for calling your API routes from client code, built on top of [ofetch](https://github.com/unjs/ofetch). Route paths and return types are inferred from the generated `RouteMap`.
|
|
529
|
-
|
|
530
|
-
```ts
|
|
531
|
-
import { fetch } from 'void/client';
|
|
532
|
-
|
|
533
|
-
// Types are fully inferred from your route handlers
|
|
534
|
-
const users = await fetch('/api/users');
|
|
535
|
-
const user = await fetch('/api/users/:id', {
|
|
536
|
-
params: { id: '1' },
|
|
537
|
-
});
|
|
538
|
-
```
|
|
539
|
-
|
|
540
|
-
**Signature:**
|
|
541
|
-
|
|
542
|
-
```ts
|
|
543
|
-
function fetch<P extends keyof RouteMap, M extends MethodsOf<P>>(
|
|
544
|
-
path: P,
|
|
545
|
-
options?: FetchOptions<P, M>,
|
|
546
|
-
): Promise<OutputOf<P, M>>;
|
|
547
|
-
```
|
|
548
|
-
|
|
549
|
-
**Options:**
|
|
550
|
-
|
|
551
|
-
| Option | Type | Description |
|
|
552
|
-
| --------- | ------------------------ | ---------------------------------------------------------- |
|
|
553
|
-
| `method` | `string` | HTTP method. Defaults to `"GET"`. |
|
|
554
|
-
| `body` | `unknown` | Request body (auto-serialized as JSON). |
|
|
555
|
-
| `query` | `Record<string, string>` | Query string parameters. |
|
|
556
|
-
| `params` | `Record<string, string>` | URL path parameters (`:id` segments). |
|
|
557
|
-
| `headers` | `HeadersInit` | Additional request headers. |
|
|
558
|
-
| `signal` | `AbortSignal` | Abort signal. |
|
|
559
|
-
| `baseURL` | `string` | Base URL prepended to the path. Useful for external calls. |
|
|
560
|
-
| `retry` | `number` | Number of retry attempts (ofetch default: 1 for GET). |
|
|
561
|
-
| `timeout` | `number` | Request timeout in milliseconds. |
|
|
562
|
-
|
|
563
|
-
Returns the parsed JSON response body, or `undefined` for 204 responses. Throws `FetchError` on non-2xx responses.
|
|
564
|
-
|
|
565
|
-
### `FetchError`
|
|
566
|
-
|
|
567
|
-
Error class thrown by `fetch` on non-2xx responses.
|
|
568
|
-
|
|
569
|
-
```ts
|
|
570
|
-
import { fetch, FetchError } from 'void/client';
|
|
571
|
-
|
|
572
|
-
try {
|
|
573
|
-
await fetch('/api/users/:id', { params: { id: '999' } });
|
|
574
|
-
} catch (e) {
|
|
575
|
-
if (e instanceof FetchError) {
|
|
576
|
-
console.log(e.status); // 404
|
|
577
|
-
console.log(e.response); // raw Response
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
```
|
|
581
|
-
|
|
582
|
-
**Properties:**
|
|
583
|
-
|
|
584
|
-
| Property | Type | Description |
|
|
585
|
-
| ---------- | ---------- | ------------------------------------ |
|
|
586
|
-
| `status` | `number` | HTTP status code. |
|
|
587
|
-
| `response` | `Response` | The raw `Response` object. |
|
|
588
|
-
| `data` | `unknown` | Parsed response body (if available). |
|
|
589
|
-
|
|
590
|
-
### Differences from Native `fetch`
|
|
591
|
-
|
|
592
|
-
The typed client is built on [ofetch](https://github.com/unjs/ofetch) with a typed route layer on top. Key differences from native `fetch`:
|
|
593
|
-
|
|
594
|
-
| Behavior | Native `fetch` | `void/client` `fetch` |
|
|
595
|
-
| ---------------------- | ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
596
|
-
| **Return type** | `Promise<Response>`, so you call `.json()` yourself | `Promise<T>`, which auto-parses JSON and returns the typed result directly (`undefined` for `204`) |
|
|
597
|
-
| **Error handling** | Resolves on any HTTP status; you check `response.ok` | Throws `FetchError` on non-2xx responses |
|
|
598
|
-
| **URL construction** | Raw URL string | Route path with `:param` interpolation from `options.params` + query string from `options.query` |
|
|
599
|
-
| **Body serialization** | Manual `JSON.stringify()` + `Content-Type` header | Auto-serializes `options.body` as JSON and sets `Content-Type: application/json` |
|
|
600
|
-
| **Type safety** | Accepts any URL or method | Constrains paths to `RouteMap` keys and methods to those defined per route. Invalid combinations fail at compile time. |
|
|
601
|
-
| **Retry** | None | Auto-retries on 408, 429, and 5xx (configurable via `retry` option) |
|
|
602
|
-
| **Timeout** | None | Configurable via `timeout` option |
|
|
603
|
-
|
|
604
|
-
`headers` and `signal` are passed through to the underlying fetch unchanged.
|
|
605
|
-
|
|
606
|
-
## Durable State
|
|
607
|
-
|
|
608
|
-
Imported from `"void/durable"`. See [Durable State](../guide/durable-state.md) for the complete file convention and deployment support.
|
|
609
|
-
|
|
610
|
-
### `defineDurableState(definition)`
|
|
611
|
-
|
|
612
|
-
Defines a typed, persisted Durable Object state machine. The returned object must be the default export of a module under `durable-objects/`; named-export the same object for typed RPC calls elsewhere in the app.
|
|
613
|
-
|
|
614
|
-
```ts
|
|
615
|
-
function defineDurableState<TState, TEnv, TMethods>(definition: {
|
|
616
|
-
initialState: TState | ((env: TEnv) => TState | Promise<TState>);
|
|
617
|
-
version?: number;
|
|
618
|
-
migrations?: Array<{
|
|
619
|
-
version: number;
|
|
620
|
-
migrate(state: unknown): TState | Promise<TState>;
|
|
621
|
-
}>;
|
|
622
|
-
methods: TMethods;
|
|
623
|
-
fetch?: (context, request: Request) => Response | Promise<Response>;
|
|
624
|
-
alarm?: (context) => void | Promise<void>;
|
|
625
|
-
storageKey?: string;
|
|
626
|
-
}): DurableStateApi<TMethods>;
|
|
627
|
-
```
|
|
628
|
-
|
|
629
|
-
`DurableStateApi` exposes `class`, `get(name)`, `get(namespace, name)`, `getById(id)`, and `getById(namespace, id)`. Stubs returned by the lookup helpers contain the definition's methods with their argument types preserved and return values wrapped in `Promise`.
|
|
630
|
-
|
|
631
|
-
## Database
|
|
632
|
-
|
|
633
|
-
Imported from `"void/db"`. The `db` export is a [Drizzle ORM](https://orm.drizzle.team) instance for the configured database dialect: [Cloudflare D1](https://developers.cloudflare.com/d1/) by default, PostgreSQL with `"database": "pg"`, or MySQL with `"database": "mysql"`.
|
|
634
|
-
|
|
635
|
-
### `db`
|
|
636
|
-
|
|
637
|
-
Default Drizzle instance, pre-wired with your schema from `db/schema.ts`.
|
|
638
|
-
|
|
639
|
-
```ts
|
|
640
|
-
import { db } from 'void/db';
|
|
641
|
-
import { users } from '@schema';
|
|
642
|
-
|
|
643
|
-
const allUsers = await db.select().from(users).all();
|
|
644
|
-
```
|
|
645
|
-
|
|
646
|
-
When the Void plugin is active, `void/db` is served as a virtual module that auto-wires the active database with your schema.
|
|
647
|
-
|
|
648
|
-
- D1 projects resolve the `DB` binding and expose `DrizzleD1Database<Schema>`.
|
|
649
|
-
- PostgreSQL projects use `DATABASE_URL` during local development and Hyperdrive's `connectionString` in production, exposing `NodePgDatabase<Schema>`.
|
|
650
|
-
- MySQL projects use the same connection sources and expose `MySql2Database<Schema>`.
|
|
651
|
-
|
|
652
|
-
The published npm fallback uses a lazy D1 proxy that resolves the `DB` binding at first access.
|
|
653
|
-
|
|
654
|
-
### `createDb(database)`
|
|
655
|
-
|
|
656
|
-
Creates a Drizzle instance for the active dialect.
|
|
657
|
-
|
|
658
|
-
For D1 projects, pass a specific D1 binding. Use this when you have multiple D1 databases or need a non-default binding.
|
|
659
|
-
|
|
660
|
-
```ts
|
|
661
|
-
import { createDb } from 'void/db';
|
|
662
|
-
import { env } from 'cloudflare:workers';
|
|
663
|
-
|
|
664
|
-
const db = createDb(env.MY_OTHER_DB);
|
|
665
|
-
```
|
|
666
|
-
|
|
667
|
-
For PostgreSQL and MySQL projects, pass a connection string.
|
|
668
|
-
|
|
669
|
-
```ts
|
|
670
|
-
import { createDb } from 'void/db';
|
|
671
|
-
|
|
672
|
-
const db = createDb('postgres://user:password@host:5432/app');
|
|
673
|
-
```
|
|
674
|
-
|
|
675
|
-
**Signature:**
|
|
676
|
-
|
|
677
|
-
```ts
|
|
678
|
-
// D1
|
|
679
|
-
function createDb(d1: D1Database): DrizzleD1Database<Schema>;
|
|
680
|
-
|
|
681
|
-
// PostgreSQL
|
|
682
|
-
function createDb(connectionString: string): NodePgDatabase<Schema>;
|
|
683
|
-
|
|
684
|
-
// MySQL
|
|
685
|
-
function createDb(connectionString: string): MySql2Database<Schema>;
|
|
686
|
-
```
|
|
687
|
-
|
|
688
|
-
### Query Operators
|
|
689
|
-
|
|
690
|
-
`void/db` re-exports commonly used [Drizzle operators](https://orm.drizzle.team/docs/operators) so you never need to depend on `drizzle-orm` directly:
|
|
691
|
-
|
|
692
|
-
```ts
|
|
693
|
-
import { db, eq, and, or, desc, like, inArray, sql } from 'void/db';
|
|
694
|
-
```
|
|
695
|
-
|
|
696
|
-
**Full list:** `sql`, `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `and`, `or`, `not`, `desc`, `asc`, `like`, `ilike`, `notLike`, `inArray`, `notInArray`, `isNull`, `isNotNull`, `between`, `notBetween`, `exists`, `notExists`, `count`, `sum`, `avg`, `min`, `max`.
|
|
697
|
-
|
|
698
|
-
## Seeding
|
|
699
|
-
|
|
700
|
-
Imported from `"void/seed"`.
|
|
701
|
-
|
|
702
|
-
### `defineSeed(fn)`
|
|
703
|
-
|
|
704
|
-
Identity helper for programmatic seed modules used by `void db seed`.
|
|
705
|
-
|
|
706
|
-
```ts
|
|
707
|
-
import { defineSeed } from 'void/seed';
|
|
708
|
-
|
|
709
|
-
export default defineSeed<typeof import('./schema')>(async ({ db, schema }) => {
|
|
710
|
-
await db.insert(schema.users).values([
|
|
711
|
-
{ name: 'Alice', email: 'alice@example.com' },
|
|
712
|
-
{ name: 'Bob', email: 'bob@example.com' },
|
|
713
|
-
]);
|
|
714
|
-
});
|
|
715
|
-
```
|
|
716
|
-
|
|
717
|
-
The callback receives:
|
|
718
|
-
|
|
719
|
-
- `dialect`: `"sqlite"` or `"postgresql"`
|
|
720
|
-
- `db`: a local Drizzle instance for the active dialect
|
|
721
|
-
- `schema`: the exports from `db/schema.ts` or `db/schema/`
|
|
722
|
-
|
|
723
|
-
Seed modules can export either `default` or a named `seed` function.
|
|
724
|
-
|
|
725
|
-
## KV
|
|
726
|
-
|
|
727
|
-
Imported from `"void/kv"`.
|
|
728
|
-
|
|
729
|
-
### `kv`
|
|
730
|
-
|
|
731
|
-
Typed JSON-aware client for the inferred `KV` binding.
|
|
732
|
-
|
|
733
|
-
```ts
|
|
734
|
-
import { kv } from 'void/kv';
|
|
735
|
-
|
|
736
|
-
await kv.put('settings', { theme: 'dark' });
|
|
737
|
-
const settings = await kv.get<{ theme: string }>('settings');
|
|
738
|
-
```
|
|
739
|
-
|
|
740
|
-
**Key exports:** `kv`, `createKV(namespace)`, `KVClient`, `KVMap`, `PutOptions`, `ListOptions`.
|
|
741
|
-
|
|
742
|
-
`kv.map(prefix)` creates a typed namespaced view where every key is stored under `prefix:`.
|
|
743
|
-
|
|
744
|
-
## Storage
|
|
745
|
-
|
|
746
|
-
Imported from `"void/storage"`.
|
|
747
|
-
|
|
748
|
-
### `storage`
|
|
749
|
-
|
|
750
|
-
Default [R2 bucket](https://developers.cloudflare.com/r2/) proxy for the inferred `STORAGE` binding.
|
|
751
|
-
|
|
752
|
-
```ts
|
|
753
|
-
import { storage } from 'void/storage';
|
|
754
|
-
|
|
755
|
-
await storage.put('avatars/alice.png', file);
|
|
756
|
-
const object = await storage.get('avatars/alice.png');
|
|
757
|
-
```
|
|
758
|
-
|
|
759
|
-
**Key exports:** `storage`, `createStorage(bucket)`.
|
|
760
|
-
|
|
761
|
-
## AI
|
|
762
|
-
|
|
763
|
-
Imported from `"void/ai"`.
|
|
764
|
-
|
|
765
|
-
### `ai`
|
|
766
|
-
|
|
767
|
-
Typed AI client for Cloudflare AI models and provider-native AI Gateway requests.
|
|
768
|
-
|
|
769
|
-
```ts
|
|
770
|
-
import { ai } from 'void/ai';
|
|
771
|
-
|
|
772
|
-
const result = await ai.run('@cf/meta/llama-3.3-70b-instruct-fp8-fast', {
|
|
773
|
-
messages: [{ role: 'user', content: 'Summarize this release note.' }],
|
|
774
|
-
});
|
|
775
|
-
|
|
776
|
-
const response = await ai.provider('openai').fetch('/chat/completions', {
|
|
777
|
-
body: {
|
|
778
|
-
model: 'gpt-4o',
|
|
779
|
-
messages: [{ role: 'user', content: 'Summarize this release note.' }],
|
|
780
|
-
},
|
|
781
|
-
});
|
|
782
|
-
```
|
|
783
|
-
|
|
784
|
-
**Key exports:** `ai`, `VoidAi`, provider request types. See [AI](../guide/ai.md) for provider setup and streaming examples.
|
|
785
|
-
|
|
786
|
-
## ISR
|
|
787
|
-
|
|
788
|
-
Imported from `"void/isr"`.
|
|
789
|
-
|
|
790
|
-
### `revalidate(options)`
|
|
791
|
-
|
|
792
|
-
Revalidate ISR-cached pages on demand. In local development this is a no-op because there is no edge ISR cache.
|
|
793
|
-
|
|
794
|
-
```ts
|
|
795
|
-
import { revalidate } from 'void/isr';
|
|
796
|
-
|
|
797
|
-
await revalidate({ paths: ['/', '/blog/hello'] });
|
|
798
|
-
await revalidate({ all: true });
|
|
799
|
-
```
|
|
800
|
-
|
|
801
|
-
**Signature:**
|
|
802
|
-
|
|
803
|
-
```ts
|
|
804
|
-
function revalidate(options: { paths?: string[]; all?: boolean }): Promise<void>;
|
|
805
|
-
```
|
|
806
|
-
|
|
807
|
-
## Logging
|
|
808
|
-
|
|
809
|
-
Imported from `"void/log"`.
|
|
810
|
-
|
|
811
|
-
### `logger`
|
|
812
|
-
|
|
813
|
-
Structured logger that emits one JSON line per call so deployed logs can be filtered by message and fields.
|
|
814
|
-
|
|
815
|
-
```ts
|
|
816
|
-
import { logger } from 'void/log';
|
|
817
|
-
|
|
818
|
-
logger.info('checkout completed', { orderId, userId });
|
|
819
|
-
logger.error('webhook failed', { provider: 'stripe', attempt: 3 });
|
|
820
|
-
```
|
|
821
|
-
|
|
822
|
-
**Methods:** `logger.error(message, fields?)`, `logger.warn(message, fields?)`, `logger.info(message, fields?)`.
|
|
823
|
-
|
|
824
|
-
## Types
|
|
825
|
-
|
|
826
|
-
### `CloudContext`
|
|
827
|
-
|
|
828
|
-
Hono `Context` pre-typed with [`CloudEnv`](#cloudenv). This is the type of the `c` parameter in all route handlers and middleware.
|
|
829
|
-
|
|
830
|
-
```ts
|
|
831
|
-
import type { CloudContext } from 'void';
|
|
832
|
-
```
|
|
833
|
-
|
|
834
|
-
### `CloudEnv`
|
|
835
|
-
|
|
836
|
-
Hono environment type for Void workers. Extends Hono's `Env` with Cloudflare bindings and context variables.
|
|
837
|
-
|
|
838
|
-
```ts
|
|
839
|
-
interface CloudEnv extends Env {
|
|
840
|
-
Bindings: {
|
|
841
|
-
DB: D1Database;
|
|
842
|
-
KV: KVNamespace;
|
|
843
|
-
STORAGE: R2Bucket;
|
|
844
|
-
AI: Ai;
|
|
845
|
-
SANDBOX: DurableObjectNamespace<import('void/sandbox').VoidPlatformSandbox>;
|
|
846
|
-
[key: string]: unknown;
|
|
847
|
-
};
|
|
848
|
-
Variables: CloudContextVariables;
|
|
849
|
-
}
|
|
850
|
-
```
|
|
851
|
-
|
|
852
|
-
### `CloudContextVariables`
|
|
853
|
-
|
|
854
|
-
The context variables type used by `c.set()` / `c.get()`. Augment this interface to add typed variables that flow through all middleware and handlers:
|
|
855
|
-
|
|
856
|
-
```ts
|
|
857
|
-
interface CloudContextVariables {
|
|
858
|
-
user: AuthUser | null;
|
|
859
|
-
session: AuthSession | null;
|
|
860
|
-
[key: string]: unknown;
|
|
861
|
-
}
|
|
862
|
-
```
|
|
863
|
-
|
|
864
|
-
**Augmentation example:**
|
|
865
|
-
|
|
866
|
-
```ts
|
|
867
|
-
declare module 'void' {
|
|
868
|
-
interface CloudContextVariables {
|
|
869
|
-
requestId: string;
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
// c.get("requestId") → string
|
|
874
|
-
```
|
|
875
|
-
|
|
876
|
-
See [Type Safety](../guide/type-safety.md#context-variables) for details.
|
|
877
|
-
|
|
878
|
-
### `TypedHandler<V, R>`
|
|
879
|
-
|
|
880
|
-
The return type of `defineHandler`. Carries phantom types for validators (`V`) and return type (`R`) used by the codegen to produce typed routes.
|
|
881
|
-
|
|
882
|
-
```ts
|
|
883
|
-
interface TypedHandler<V extends ValidatorSlots = {}, R = unknown> {
|
|
884
|
-
(c: CloudContext): Promise<Response> | Response | unknown;
|
|
885
|
-
readonly __validators: V; // type-level only
|
|
886
|
-
readonly __output: R; // type-level only
|
|
887
|
-
}
|
|
888
|
-
```
|
|
889
|
-
|
|
890
|
-
### `HeadDescriptor`
|
|
891
|
-
|
|
892
|
-
Shape of page head metadata returned by `defineHead`. All fields are optional.
|
|
893
|
-
|
|
894
|
-
```ts
|
|
895
|
-
interface HeadDescriptor {
|
|
896
|
-
title?: string;
|
|
897
|
-
meta?: Array<{ name?: string; property?: string; content?: string; charset?: string }>;
|
|
898
|
-
link?: Array<{ rel: string; href: string; [key: string]: string | undefined }>;
|
|
899
|
-
script?: Array<{ src?: string; innerHTML?: string; [key: string]: string | undefined }>;
|
|
900
|
-
htmlAttrs?: Record<string, string>;
|
|
901
|
-
bodyAttrs?: Record<string, string>;
|
|
902
|
-
}
|
|
903
|
-
```
|
|
904
|
-
|
|
905
|
-
### `RouteMap`
|
|
906
|
-
|
|
907
|
-
Empty stub interface augmented at build time by the generated `.void/routes.d.ts`. It contains the full type information for routes, methods, inputs, and outputs, and the typed `fetch` client reads from it.
|
|
908
|
-
|
|
909
|
-
```ts
|
|
910
|
-
import type { RouteMap } from 'void/routes';
|
|
911
|
-
```
|
|
912
|
-
|
|
913
|
-
## Environment
|
|
914
|
-
|
|
915
|
-
Imported from `"void/env"`.
|
|
916
|
-
|
|
917
|
-
### `defineEnv(schema)`
|
|
918
|
-
|
|
919
|
-
Register an env schema and return the typed [`env`](#env) proxy. Void auto-discovers `env.ts`, imports it during dev/build/deploy, generates `.void/env.d.ts`, validates production secrets before deploy, and validates values at worker boot.
|
|
920
|
-
|
|
921
|
-
```ts
|
|
922
|
-
import { defineEnv, string, number, oneOf, url } from 'void/env';
|
|
923
|
-
|
|
924
|
-
export default defineEnv({
|
|
925
|
-
STRIPE_KEY: string(),
|
|
926
|
-
PORT: number().default(3000),
|
|
927
|
-
NODE_ENV: oneOf(['development', 'production']),
|
|
928
|
-
VITE_PUBLIC_URL: url(),
|
|
929
|
-
});
|
|
930
|
-
```
|
|
931
|
-
|
|
932
|
-
### `env`
|
|
933
|
-
|
|
934
|
-
Typed runtime proxy for declared env keys. Unknown keys and bindings pass through as `unknown`.
|
|
935
|
-
|
|
936
|
-
```ts
|
|
937
|
-
import { env } from 'void/env';
|
|
938
|
-
|
|
939
|
-
const port = env.PORT;
|
|
940
|
-
```
|
|
941
|
-
|
|
942
|
-
### Schema helpers
|
|
943
|
-
|
|
944
|
-
`void/env` includes Standard Schema-compatible helpers: `string()`, `number()`, `boolean()`, `url()`, `email()`, `oneOf([...])`, and `json<T>()`. Each helper supports `.optional()` and `.default(value)`.
|
|
945
|
-
|
|
946
|
-
Non-client keys are server values and use remote secret storage in production. `VITE_*` keys are public build-time client values. Invalid input is redacted uniformly; storage is not selected with schema modifiers.
|
|
947
|
-
|
|
948
|
-
### Types
|
|
949
|
-
|
|
950
|
-
`void/env` also provides global Cloudflare environment types:
|
|
951
|
-
|
|
952
|
-
```ts
|
|
953
|
-
/// <reference types="void/env" />
|
|
954
|
-
```
|
|
955
|
-
|
|
956
|
-
Declares the `Cloudflare.Env` namespace with `DB`, `KV`, `STORAGE`, `AI`, and `SANDBOX` binding types.
|
|
957
|
-
|
|
958
|
-
For handler context variables such as `c.set()` and `c.get()`, augment [`CloudContextVariables`](#cloudcontextvariables). This is separate from `Cloudflare.Env`, which types worker bindings. Framework adapters such as `@void/vue`, `@void/react`, and `@void/svelte` also augment `CloudContextVariables` to add the `shared` key used by `useShared()`.
|
|
959
|
-
|
|
960
|
-
## Framework Adaptors
|
|
961
|
-
|
|
962
|
-
Framework adaptors for [Pages Routing](../guide/pages-routing/overview). Each adaptor provides a Vite plugin and client-side runtime.
|
|
963
|
-
|
|
964
|
-
### `@void/vue`
|
|
965
|
-
|
|
966
|
-
#### `voidVue(options?)`
|
|
967
|
-
|
|
968
|
-
Imported from `"@void/vue/plugin"`. Returns an array of Vite plugins that handle Vue SFC compilation and SSR or hydration entry generation. It already includes `@vitejs/plugin-vue`, so you do not need to install or configure that separately.
|
|
969
|
-
|
|
970
|
-
```ts
|
|
971
|
-
import { voidVue } from '@void/vue/plugin';
|
|
972
|
-
|
|
973
|
-
export default defineConfig({
|
|
974
|
-
plugins: [voidPlugin(), voidVue()],
|
|
975
|
-
});
|
|
976
|
-
```
|
|
977
|
-
|
|
978
|
-
**Signature:**
|
|
979
|
-
|
|
980
|
-
```ts
|
|
981
|
-
function voidVue(options?: VoidVueOptions): Plugin[];
|
|
982
|
-
```
|
|
983
|
-
|
|
984
|
-
**Options:**
|
|
985
|
-
|
|
986
|
-
```ts
|
|
987
|
-
interface VoidVueOptions {
|
|
988
|
-
vue?: VuePluginOptions; // passed through to @vitejs/plugin-vue
|
|
989
|
-
viewTransitions?: boolean; // enable View Transitions API for navigations
|
|
990
|
-
}
|
|
991
|
-
```
|
|
992
|
-
|
|
993
|
-
#### Vue Runtime
|
|
994
|
-
|
|
995
|
-
Imported from `"@void/vue"`.
|
|
996
|
-
|
|
997
|
-
| Export | Description |
|
|
998
|
-
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
999
|
-
| `Link` | Vue component for SPA navigation. Renders `<a>` for GET, `<button>` for non-GET methods. Props: `href`, `method`, `data`, `prefetch`, `cacheFor`, `preserveScroll`, `preserveState`, `replace`, `reloadDocument`, `viewTransition`, `onNavigate`. |
|
|
1000
|
-
| `useRouter()` | Returns the Void Router with current route state (`url`, `path`, `query`, `params`) and navigation methods: `visit`, `refresh`, awaitable `prefetch`, `flush`, `flushAll`. |
|
|
1001
|
-
| `useParams()` | Returns dynamic route params for the page currently being rendered. |
|
|
1002
|
-
| `useNavigation()` | Returns pending navigation state: `{ state, location, method }`, where `state` is `"idle"`, `"loading"`, or `"submitting"` and `location` is the pending destination. |
|
|
1003
|
-
| `useForm(url, defaults, options?)` | Typed reactive form helper bound to a page action URL. Returns `{ data, post, put, patch, delete, pending, errors, error, hasChanges, wasSuccessful, recentlySuccessful, reset, clearErrors, clearError }`. |
|
|
1004
|
-
| `useIslandForm(defaults)` | Form helper for island components where the action URL is inferred from the current island request. Returns the same form state and submit helpers as `useForm()`. |
|
|
1005
|
-
| `action(url, options?)` | Awaitable one-shot page action helper. Uses `POST` by default and accepts `{ data, method, params }`, where `method` can be `"PUT"`, `"PATCH"`, or `"DELETE"`. Returns an `ActionResult`. |
|
|
1006
|
-
| `useShared()` | Returns shared data injected by middleware via `c.set("shared", {...})`. |
|
|
1007
|
-
|
|
1008
|
-
Vue `Link` GET `data` is merged into the rendered `href` query string. Primitive values are serialized with `String(value)`, arrays become repeated keys, `null` and `undefined` are omitted, and nested objects throw. `prefetch` and `reloadDocument` are GET-only and throw for mutation links.
|
|
1009
|
-
|
|
1010
|
-
Vue GET navigation remounts the page so `useForm()` picks up the destination record's URL and defaults; layouts persist. Mutations and `router.refresh()` preserve page state by default. Set `preserveState` explicitly to override the default for navigation within the same record.
|
|
1011
|
-
|
|
1012
|
-
### `@void/react`
|
|
1013
|
-
|
|
1014
|
-
#### `voidReact(options?)`
|
|
1015
|
-
|
|
1016
|
-
Imported from `"@void/react/plugin"`. Returns an array of Vite plugins that handle SSR and hydration entry generation. It already includes `@vitejs/plugin-react`, so you do not need to install or configure that separately.
|
|
1017
|
-
|
|
1018
|
-
```ts
|
|
1019
|
-
import { voidReact } from '@void/react/plugin';
|
|
1020
|
-
|
|
1021
|
-
export default defineConfig({
|
|
1022
|
-
plugins: [voidPlugin(), voidReact()],
|
|
1023
|
-
});
|
|
1024
|
-
```
|
|
1025
|
-
|
|
1026
|
-
**Signature:**
|
|
1027
|
-
|
|
1028
|
-
```ts
|
|
1029
|
-
function voidReact(options?: VoidReactOptions): Plugin[];
|
|
1030
|
-
```
|
|
1031
|
-
|
|
1032
|
-
**Options:**
|
|
1033
|
-
|
|
1034
|
-
```ts
|
|
1035
|
-
interface VoidReactOptions {
|
|
1036
|
-
react?: ReactPluginOptions; // passed through to @vitejs/plugin-react
|
|
1037
|
-
viewTransitions?: boolean; // enable View Transitions API for navigations
|
|
1038
|
-
prefetch?: {
|
|
1039
|
-
hoverDelay?: number;
|
|
1040
|
-
cacheFor?: number | string | [string, string];
|
|
1041
|
-
};
|
|
1042
|
-
}
|
|
1043
|
-
```
|
|
1044
|
-
|
|
1045
|
-
#### React Runtime
|
|
1046
|
-
|
|
1047
|
-
Imported from `"@void/react"`.
|
|
1048
|
-
|
|
1049
|
-
| Export | Description |
|
|
1050
|
-
| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1051
|
-
| `Link` | React component for SPA navigation. Renders `<a>` for GET, `<button>` for non-GET methods. Props: `href`, `method`, `data`, `prefetch`, `cacheFor`, `preserveScroll`, `preserveState`, `replace`, `reloadDocument`, `viewTransition`, `onNavigate`. |
|
|
1052
|
-
| `useRouter()` | Returns the Void Router with current route state (`url`, `path`, `query`, `params`) and navigation methods: `visit`, `refresh`, awaitable `prefetch`, `flush`, `flushAll`. React navigations are scheduled as transitions. |
|
|
1053
|
-
| `useParams()` | Returns dynamic route params for the page currently being rendered. |
|
|
1054
|
-
| `useNavigation()` | Returns pending navigation state: `{ state, location, method }`, where `state` is `"idle"`, `"loading"`, or `"submitting"` and `location` is the pending destination. |
|
|
1055
|
-
| `useForm(url, defaults, options?)` | Form helper hook. Returns `{ data, setData, post, put, patch, delete, pending, errors, error, hasChanges, wasSuccessful, recentlySuccessful, reset, clearErrors, clearError }`. |
|
|
1056
|
-
| `useIslandForm(defaults)` | Form helper hook for island components where the action URL is inferred from the current island request. Returns the same form state and submit helpers as `useForm()`. |
|
|
1057
|
-
| `action(url, options?)` | Awaitable one-shot page action helper. Uses `POST` by default and accepts `{ data, method, params }`, where `method` can be `"PUT"`, `"PATCH"`, or `"DELETE"`. Returns an `ActionResult`. |
|
|
1058
|
-
| `useShared()` | Returns shared data injected by middleware via `c.set("shared", {...})`. |
|
|
1059
|
-
| `Deferred<T>` | React-only prop type for `defer()` results. It is `Promise<T>` and is consumed with React `use()`. |
|
|
1060
|
-
|
|
1061
|
-
React `Link` GET `data` is merged into the rendered `href` query string. Primitive values are serialized with `String(value)`, arrays become repeated keys, `null` and `undefined` are omitted, and nested objects throw. `prefetch` and `reloadDocument` are GET-only and throw for mutation links.
|
|
1062
|
-
|
|
1063
|
-
React deferred props returned from `defer()` are Suspense resources. Read them
|
|
1064
|
-
with React's `use()` inside a `<Suspense>` boundary. React Pages requires React
|
|
1065
|
-
19 and uses streaming SSR for the initial deferred shell. Rejections throw from
|
|
1066
|
-
`use()`, so use a normal React error boundary for custom deferred error UI. Vue,
|
|
1067
|
-
Svelte, and Solid keep the `{ loading, value, error }` deferred state object.
|
|
1068
|
-
When explicitly annotating props, import `Deferred` from the framework adapter
|
|
1069
|
-
package (`@void/react`, `@void/vue`, `@void/svelte`, or `@void/solid`) so the
|
|
1070
|
-
type matches that adapter's client runtime shape.
|
|
1071
|
-
|
|
1072
|
-
### `@void/svelte`
|
|
1073
|
-
|
|
1074
|
-
#### `voidSvelte(options?)`
|
|
1075
|
-
|
|
1076
|
-
Imported from `"@void/svelte/plugin"`. Returns an array of Vite plugins that handle SSR and hydration entry generation for Svelte 5. It already includes `@sveltejs/vite-plugin-svelte`, so you do not need to install or configure that separately.
|
|
1077
|
-
|
|
1078
|
-
```ts
|
|
1079
|
-
import { voidSvelte } from '@void/svelte/plugin';
|
|
1080
|
-
|
|
1081
|
-
export default defineConfig({
|
|
1082
|
-
plugins: [voidPlugin(), voidSvelte()],
|
|
1083
|
-
});
|
|
1084
|
-
```
|
|
1085
|
-
|
|
1086
|
-
**Signature:**
|
|
1087
|
-
|
|
1088
|
-
```ts
|
|
1089
|
-
function voidSvelte(options?: VoidSvelteOptions): Plugin[];
|
|
1090
|
-
```
|
|
1091
|
-
|
|
1092
|
-
**Options:**
|
|
1093
|
-
|
|
1094
|
-
```ts
|
|
1095
|
-
interface VoidSvelteOptions {
|
|
1096
|
-
svelte?: SveltePluginOptions; // passed through to @sveltejs/vite-plugin-svelte
|
|
1097
|
-
viewTransitions?: boolean; // enable View Transitions API
|
|
1098
|
-
prefetch?: {
|
|
1099
|
-
hoverDelay?: number;
|
|
1100
|
-
cacheFor?: number | string | [string, string];
|
|
1101
|
-
};
|
|
1102
|
-
}
|
|
1103
|
-
```
|
|
1104
|
-
|
|
1105
|
-
#### Svelte Runtime
|
|
1106
|
-
|
|
1107
|
-
Imported from `"@void/svelte"`.
|
|
1108
|
-
|
|
1109
|
-
| Export | Description |
|
|
1110
|
-
| ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1111
|
-
| `Link` | Svelte component for SPA navigation. Renders `<a>` for GET, `<button>` for non-GET methods. Props: `href`, `method`, `data`, `prefetch`, `cacheFor`, `preserveScroll`, `preserveState`, `replace`, `reloadDocument`, `viewTransition`, `onNavigate`. |
|
|
1112
|
-
| `useForm(url, defaults, options?)` | Form helper using Svelte 5 runes. Returns `{ data, post, put, patch, delete, pending, errors, error, hasChanges, wasSuccessful, recentlySuccessful, reset, clearErrors, clearError }`. |
|
|
1113
|
-
| `useIslandForm(defaults)` | Form helper for island components where the action URL is inferred from the current island request. Returns the same form state and submit helpers as `useForm()`. |
|
|
1114
|
-
| `action(url, options?)` | Awaitable one-shot page action helper. Uses `POST` by default and accepts `{ data, method, params }`, where `method` can be `"PUT"`, `"PATCH"`, or `"DELETE"`. Returns an `ActionResult`. |
|
|
1115
|
-
| `useShared()` | Returns shared data injected by middleware via `c.set("shared", {...})`. |
|
|
1116
|
-
| `useRouter()` | Returns the Void Router with current route state (`url`, `path`, `query`, `params`) and navigation methods: `visit`, `refresh`, awaitable `prefetch`, `flush`, `flushAll`. |
|
|
1117
|
-
| `useParams()` | Returns dynamic route params for the page currently being rendered. |
|
|
1118
|
-
| `useNavigation()` | Returns pending navigation state: `{ state, location, method }`, where `state` is `"idle"`, `"loading"`, or `"submitting"` and `location` is the pending destination. |
|
|
1119
|
-
|
|
1120
|
-
Svelte `Link` GET `data` is merged into the rendered `href` query string. Primitive values are serialized with `String(value)`, arrays become repeated keys, `null` and `undefined` are omitted, and nested objects throw. `prefetch` and `reloadDocument` are GET-only and throw for mutation links.
|
|
1121
|
-
|
|
1122
|
-
### `@void/solid`
|
|
1123
|
-
|
|
1124
|
-
#### `voidSolid(options?)`
|
|
1125
|
-
|
|
1126
|
-
Imported from `"@void/solid/plugin"`. Returns an array of Vite plugins that handle SSR and hydration entry generation for Solid. It already includes `vite-plugin-solid`, so you do not need to install or configure that separately.
|
|
1127
|
-
|
|
1128
|
-
```ts
|
|
1129
|
-
import { voidSolid } from '@void/solid/plugin';
|
|
1130
|
-
|
|
1131
|
-
export default defineConfig({
|
|
1132
|
-
plugins: [voidPlugin(), voidSolid()],
|
|
1133
|
-
});
|
|
1134
|
-
```
|
|
1135
|
-
|
|
1136
|
-
**Signature:**
|
|
1137
|
-
|
|
1138
|
-
```ts
|
|
1139
|
-
function voidSolid(options?: VoidSolidOptions): Plugin[];
|
|
1140
|
-
```
|
|
1141
|
-
|
|
1142
|
-
**Options:**
|
|
1143
|
-
|
|
1144
|
-
```ts
|
|
1145
|
-
interface VoidSolidOptions {
|
|
1146
|
-
solid?: SolidPluginOptions; // passed through to vite-plugin-solid
|
|
1147
|
-
viewTransitions?: boolean; // enable View Transitions API
|
|
1148
|
-
prefetch?: {
|
|
1149
|
-
hoverDelay?: number;
|
|
1150
|
-
cacheFor?: number | string | [string, string];
|
|
1151
|
-
};
|
|
1152
|
-
}
|
|
1153
|
-
```
|
|
1154
|
-
|
|
1155
|
-
#### Solid Runtime
|
|
1156
|
-
|
|
1157
|
-
Imported from `"@void/solid"`.
|
|
1158
|
-
|
|
1159
|
-
| Export | Description |
|
|
1160
|
-
| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1161
|
-
| `Link` | Solid component for SPA navigation. Renders `<a>` for GET, `<button>` for non-GET methods. Props: `href`, `method`, `data`, `prefetch`, `cacheFor`, `preserveScroll`, `preserveState`, `replace`, `reloadDocument`, `viewTransition`, `onNavigate`. |
|
|
1162
|
-
| `useForm(url, defaults, options?)` | Form helper using Solid stores. Returns `{ data, setData, post, put, patch, delete, pending, errors, error, hasChanges, wasSuccessful, recentlySuccessful, reset, clearErrors, clearError }`. |
|
|
1163
|
-
| `useIslandForm(defaults)` | Form helper for island components where the action URL is inferred from the current island request. Returns the same form state and submit helpers as `useForm()`. |
|
|
1164
|
-
| `action(url, options?)` | Awaitable one-shot page action helper. Uses `POST` by default and accepts `{ data, method, params }`, where `method` can be `"PUT"`, `"PATCH"`, or `"DELETE"`. Returns an `ActionResult`. |
|
|
1165
|
-
| `useShared()` | Returns shared data injected by middleware via `c.set("shared", {...})`. |
|
|
1166
|
-
| `useRouter()` | Returns the Void Router with current route state (`url`, `path`, `query`, `params`) and navigation methods: `visit`, `refresh`, awaitable `prefetch`, `flush`, `flushAll`. |
|
|
1167
|
-
| `useParams()` | Returns dynamic route params for the page currently being rendered. |
|
|
1168
|
-
| `useNavigation()` | Returns pending navigation state: `{ state, location, method }`, where `state` is `"idle"`, `"loading"`, or `"submitting"` and `location` is the pending destination. |
|
|
1169
|
-
|
|
1170
|
-
Solid `Link` GET `data` is merged into the rendered `href` query string. Primitive values are serialized with `String(value)`, arrays become repeated keys, `null` and `undefined` are omitted, and nested objects throw. `prefetch` and `reloadDocument` are GET-only and throw for mutation links.
|
|
1171
|
-
|
|
1172
|
-
## Markdown Package
|
|
1173
|
-
|
|
1174
|
-
The optional `@void/md` package adds Markdown pages to Pages Routing. Install it alongside a Pages adapter and add `voidMarkdown()` to your Vite plugins.
|
|
1175
|
-
|
|
1176
|
-
```ts
|
|
1177
|
-
import { voidMarkdown } from '@void/md/plugin';
|
|
1178
|
-
|
|
1179
|
-
export default defineConfig({
|
|
1180
|
-
plugins: [voidPlugin(), voidReact(), voidMarkdown()],
|
|
1181
|
-
});
|
|
1182
|
-
```
|
|
1183
|
-
|
|
1184
|
-
| Import path | Contents |
|
|
1185
|
-
| ---------------------------- | ---------------------------------------------------------------------------------------- |
|
|
1186
|
-
| `@void/md/plugin` | `voidMarkdown(options?)`, `MarkdownOptions`, `MdPage` |
|
|
1187
|
-
| `@void/md` | `useFrontmatter()`, `FrontmatterContext`, `setFrontmatter()`, `MdPage` |
|
|
1188
|
-
| `@void/md/pages` | Generated metadata for Markdown pages, used for navigation, sidebars, and search indexes |
|
|
1189
|
-
| `@void/md/theme.css` | Full Markdown theme styles |
|
|
1190
|
-
| `@void/md/theme-content.css` | Content-only Markdown styles for apps that provide their own shell/layout |
|
|
1191
|
-
|
|
1192
|
-
See [Markdown Pages](../guide/pages-routing/markdown.md) for setup and framework-specific examples.
|
|
1193
|
-
|
|
1194
|
-
## User-Facing Imports
|
|
32
|
+
## User-Facing Imports {#user-facing-imports}
|
|
1195
33
|
|
|
1196
34
|
Import Void's app-facing APIs from these paths:
|
|
1197
35
|
|
|
1198
|
-
| Import path | Contents
|
|
1199
|
-
| ------------------------- |
|
|
1200
|
-
| `void` | `voidPlugin`, handler/type re-exports, `defer`, `Deferred`, `DeferredState`, `InferProps`, `HeadDescriptor`
|
|
1201
|
-
| `void/handler` | `defineHandler`, `defineMiddleware`, `basicAuth`, `defineScheduled`, `defineQueue`, `defineRender`, `defineHead`, types
|
|
1202
|
-
| `void/auth` | `defineAuth`, `getUser`, `getSession`, `requireAuth`, `AuthUser`, `AuthSession`, `AuthState`
|
|
1203
|
-
| `void/client` | `fetch`, `fetchStream`, `FetchError`, `auth`, `createAuthClient`, `AuthUser`, `AuthSession`, `AuthState`
|
|
1204
|
-
| `void/client/{framework}` | Same as `void/client`, with framework-specific Better Auth clients for `react`, `vue`, `svelte`, and `solid`
|
|
1205
|
-
| `void/ws` | `defineRoom`, `defineWebSocket`, `connect`, WebSocket context and connection types
|
|
1206
|
-
| `void/durable` | `defineDurableState`, typed state/RPC/context/migration types
|
|
1207
|
-
| `void/sse` | `eventStream`, `formatSse`, `formatSseText`, `getLastEventId`, `SseStreamClosedError`, SSE message and stream types
|
|
1208
|
-
| `void/sse/client` | `connectEventStream`, browser `EventSource` wrapper types
|
|
1209
|
-
| `void/live` | `defineLiveStream`, SSE topic fanout runtime types. Server-only.
|
|
1210
|
-
| `void/live/client` | `connectLiveStream`, browser helper for one SSE connection plus POST subscribe/unsubscribe control.
|
|
1211
|
-
| `void/response` | `convertReturnValue`
|
|
1212
|
-
| `void/validator` | `runValidation`, `ValidatorSlots`, `HandlerInput`
|
|
1213
|
-
| `void/drizzle-zod` | Re-exports [`drizzle-zod`](https://orm.drizzle.team/docs/zod) for schema-derived Zod validators for Drizzle tables
|
|
1214
|
-
| `void/drizzle-valibot` | Re-exports [`drizzle-valibot`](https://orm.drizzle.team/docs/typebox) for schema-derived Valibot validators for Drizzle tables
|
|
1215
|
-
| `void/drizzle-arktype` | Re-exports [`drizzle-arktype`](https://orm.drizzle.team/docs/arktype) for schema-derived ArkType validators for Drizzle tables
|
|
1216
|
-
| `void/schema-d1` | Re-exports [`drizzle-orm/sqlite-core`](https://orm.drizzle.team/docs/column-types/sqlite) for D1 table and column builders
|
|
1217
|
-
| `void/schema-pg` | Re-exports [`drizzle-orm/pg-core`](https://orm.drizzle.team/docs/column-types/pg) for PostgreSQL table and column builders
|
|
1218
|
-
| `void/schema-mysql` | Re-exports `drizzle-orm/mysql-core` for MySQL table and column builders
|
|
1219
|
-
| `void/database-provider` | `defineDatabaseProvider` and adapter types for `void db connect --provider`
|
|
1220
|
-
| `void/db` | `db` (Drizzle D1, PostgreSQL, or MySQL instance for the active dialect), `createDb`, query operators (`eq`, `and`, `or`, `desc`, `like`, `inArray`, etc.)
|
|
1221
|
-
| `void/seed` | `defineSeed`, `SeedContext`, `SeedFn` for programmatic `void db seed` modules
|
|
1222
|
-
| `void/kv` | `kv`, `createKV`, typed KV client/map types
|
|
1223
|
-
| `void/storage` | `storage`, `createStorage` for the inferred R2 binding or a specific `R2Bucket`
|
|
1224
|
-
| `void/ai` | `ai`, `VoidAi`, model input and response types
|
|
1225
|
-
| `void/isr` | `revalidate(options)` for on-demand ISR cache invalidation
|
|
1226
|
-
| `void/log` | `logger` structured logging helper
|
|
1227
|
-
| `void/routes` | `RouteMap` and `WebSocketRouteMap` stubs (types only)
|
|
1228
|
-
| `void/queues` | `queues` proxy for sending messages to typed queues
|
|
1229
|
-
| `void/sandbox` | `getSandbox`, `sandbox`, `SandboxLimitError`, `SandboxUnavailableError`, and the SDK 1.0 file, backup, and mount helpers. `getSandbox(id)`
|
|
1230
|
-
| `void/env` | `defineEnv`, `env`, schema helpers (`string`, `number`, `boolean`, `url`, `email`, `oneOf`, `json`), and global Cloudflare env types
|
|
1231
|
-
| `void/sveltekit` | SvelteKit integration helpers: `withVoidTSConfig()` and `mergeVoidSvelteKitTsconfig()`
|
|
36
|
+
| Import path | Contents |
|
|
37
|
+
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
38
|
+
| `void` | `voidPlugin`, handler/type re-exports, `defer`, `Deferred`, `DeferredState`, `InferProps`, `HeadDescriptor` |
|
|
39
|
+
| `void/handler` | `defineHandler`, `defineMiddleware`, `basicAuth`, `defineScheduled`, `defineQueue`, `defineRender`, `defineHead`, types |
|
|
40
|
+
| `void/auth` | `defineAuth`, `getUser`, `getSession`, `requireAuth`, `AuthUser`, `AuthSession`, `AuthState` |
|
|
41
|
+
| `void/client` | `fetch`, `fetchStream`, `FetchError`, `auth`, `createAuthClient`, `AuthUser`, `AuthSession`, `AuthState` |
|
|
42
|
+
| `void/client/{framework}` | Same as `void/client`, with framework-specific Better Auth clients for `react`, `vue`, `svelte`, and `solid` |
|
|
43
|
+
| `void/ws` | `defineRoom`, `defineWebSocket`, `connect`, WebSocket context and connection types |
|
|
44
|
+
| `void/durable` | `defineDurableState`, typed state/RPC/context/migration types |
|
|
45
|
+
| `void/sse` | `eventStream`, `formatSse`, `formatSseText`, `getLastEventId`, `SseStreamClosedError`, SSE message and stream types |
|
|
46
|
+
| `void/sse/client` | `connectEventStream`, browser `EventSource` wrapper types |
|
|
47
|
+
| `void/live` | `defineLiveStream`, SSE topic fanout runtime types. Server-only. |
|
|
48
|
+
| `void/live/client` | `connectLiveStream`, browser helper for one SSE connection plus POST subscribe/unsubscribe control. |
|
|
49
|
+
| `void/response` | `convertReturnValue` |
|
|
50
|
+
| `void/validator` | `runValidation`, `ValidatorSlots`, `HandlerInput` |
|
|
51
|
+
| `void/drizzle-zod` | Re-exports [`drizzle-zod`](https://orm.drizzle.team/docs/zod) for schema-derived Zod validators for Drizzle tables |
|
|
52
|
+
| `void/drizzle-valibot` | Re-exports [`drizzle-valibot`](https://orm.drizzle.team/docs/typebox) for schema-derived Valibot validators for Drizzle tables |
|
|
53
|
+
| `void/drizzle-arktype` | Re-exports [`drizzle-arktype`](https://orm.drizzle.team/docs/arktype) for schema-derived ArkType validators for Drizzle tables |
|
|
54
|
+
| `void/schema-d1` | Re-exports [`drizzle-orm/sqlite-core`](https://orm.drizzle.team/docs/column-types/sqlite) for D1 table and column builders |
|
|
55
|
+
| `void/schema-pg` | Re-exports [`drizzle-orm/pg-core`](https://orm.drizzle.team/docs/column-types/pg) for PostgreSQL table and column builders |
|
|
56
|
+
| `void/schema-mysql` | Re-exports `drizzle-orm/mysql-core` for MySQL table and column builders |
|
|
57
|
+
| `void/database-provider` | `defineDatabaseProvider` and adapter types for `void db connect --provider` |
|
|
58
|
+
| `void/db` | `db` (Drizzle D1, PostgreSQL, or MySQL instance for the active dialect), `createDb`, query operators (`eq`, `and`, `or`, `desc`, `like`, `inArray`, etc.) |
|
|
59
|
+
| `void/seed` | `defineSeed`, `SeedContext`, `SeedFn` for programmatic `void db seed` modules |
|
|
60
|
+
| `void/kv` | `kv`, `createKV`, typed KV client/map types |
|
|
61
|
+
| `void/storage` | `storage`, `createStorage` for the inferred R2 binding or a specific `R2Bucket` |
|
|
62
|
+
| `void/ai` | `ai`, `VoidAi`, model input and response types |
|
|
63
|
+
| `void/isr` | `revalidate(options)` for on-demand ISR cache invalidation |
|
|
64
|
+
| `void/log` | `logger` structured logging helper |
|
|
65
|
+
| `void/routes` | `RouteMap` and `WebSocketRouteMap` stubs (types only) |
|
|
66
|
+
| `void/queues` | `queues` proxy for sending messages to typed queues |
|
|
67
|
+
| `void/sandbox` | `getSandbox`, `sandbox`, `SandboxLimitError`, `SandboxUnavailableError`, and the SDK 1.0 file, backup, and mount helpers. `getSandbox(id)` resolves a client. Commands, files, port requests and process completion require `.match({ ok, limited })`; `run()` collects output through one matched operation. Container state lasts until inactivity (default ten minutes), a crash, or a restart. See [Sandboxes](../guide/sandboxes.md) for the API and deployment requirements. |
|
|
68
|
+
| `void/env` | `defineEnv`, `env`, schema helpers (`string`, `number`, `boolean`, `url`, `email`, `oneOf`, `json`), and global Cloudflare env types |
|
|
69
|
+
| `void/sveltekit` | SvelteKit integration helpers: `withVoidTSConfig()` and `mergeVoidSvelteKitTsconfig()` |
|