void 0.1.6 → 0.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/AGENT_PROMPT.md +15 -0
- package/README.md +62 -123
- package/dist/auth-BdsJ0Aff.d.mts +43 -0
- package/dist/auth-cmd-Dx8oPKZC.mjs +43 -0
- package/dist/auth-migrations-BAtAck2g.mjs +117 -0
- package/dist/better-auth-shared-C9_GHSkR.d.mts +71 -0
- package/dist/better-auth-shared-CdYmQGry.mjs +163 -0
- package/dist/cache-W82I8ihI.mjs +47 -0
- package/dist/cancel-deploy-BOBTqqh0.mjs +59 -0
- package/dist/cf-access-Dee5cXxL.mjs +22 -0
- package/dist/chunk-DJd-R1mw.mjs +34 -0
- package/dist/cli/cli.d.mts +1 -0
- package/dist/cli/cli.mjs +1807 -0
- package/dist/client-snXOjrp1.mjs +565 -0
- package/dist/collect-CjeZgz5D.mjs +55 -0
- package/dist/config-BIa9HwVX.mjs +573 -0
- package/dist/config-BzM9Dy7T.mjs +37 -0
- package/dist/config-CvHtTM0q.mjs +30 -0
- package/dist/create-project-BIA15W7z.mjs +90 -0
- package/dist/db-DsRoMcfN.mjs +895 -0
- package/dist/defer-DcxEsVH1.mjs +49 -0
- package/dist/delete-DAP6yDc7.mjs +64 -0
- package/dist/deploy-BPKblFx6.mjs +2424 -0
- package/dist/discover-B7FkXBLB.mjs +40 -0
- package/dist/dist-DUyXJLkq.mjs +2667 -0
- package/dist/dist-Dayj3gCK.mjs +1287 -0
- package/dist/domain-BGofcQ6I.mjs +79 -0
- package/dist/dotenv-DwO4ti0Z.mjs +173 -0
- package/dist/drizzle-NnudE_UN.mjs +232 -0
- package/dist/env-CyG3tvU0.mjs +301 -0
- package/dist/env-helpers-Dr9Y7RnE.d.mts +52 -0
- package/dist/env-raw-BDL4TvdN.mjs +32 -0
- package/dist/env-types-DknSA4SO.mjs +64 -0
- package/dist/env-validation-DJKjR_8q.mjs +163 -0
- package/dist/fetch-error-BQ8sZ5Nd.mjs +266 -0
- package/dist/fetch-error-CVZ5CGA-.d.mts +20 -0
- package/dist/gen-U0Ktr4Zd.mjs +761 -0
- package/dist/handler-B0ds0OHJ.d.mts +269 -0
- package/dist/head-P-egrtFE.d.mts +45 -0
- package/dist/headers-DCXc7mDs.mjs +279 -0
- package/dist/index.d.mts +32 -0
- package/dist/index.mjs +4695 -0
- package/dist/init-C7wS5iGP.mjs +2625 -0
- package/dist/link-p2R6NbgN.mjs +49 -0
- package/dist/list-Bfel-QLc.mjs +113 -0
- package/dist/log-DXdqnmhF.mjs +26 -0
- package/dist/login-CkcXUiIu.mjs +72 -0
- package/dist/logs-DmkrRvx6.mjs +98 -0
- package/dist/magic-string.es-D6g9UnIy.mjs +1011 -0
- package/dist/mcp-CaQzfeUi.mjs +373 -0
- package/dist/node-DDfXj10V.mjs +54 -0
- package/dist/output-BwlcIYSR.mjs +139 -0
- package/dist/pages/client.d.mts +198 -0
- package/dist/pages/client.mjs +980 -0
- package/dist/pages/head-client.d.mts +15 -0
- package/dist/pages/head-client.mjs +90 -0
- package/dist/pages/head.d.mts +2 -0
- package/dist/pages/head.mjs +112 -0
- package/dist/pages/index.d.mts +38 -0
- package/dist/pages/index.mjs +76 -0
- package/dist/pages/islands-plugin.d.mts +50 -0
- package/dist/pages/islands-plugin.mjs +195 -0
- package/dist/pages/prefetch.d.mts +31 -0
- package/dist/pages/prefetch.mjs +90 -0
- package/dist/pages/protocol.d.mts +3 -0
- package/dist/pages/protocol.mjs +193 -0
- package/dist/pages/serialize.d.mts +10 -0
- package/dist/pages/serialize.mjs +14 -0
- package/dist/pathe.M-eThtNZ-D-kmWkCS.mjs +150 -0
- package/dist/plugin-inference-oZ6Ybu2_.mjs +2447 -0
- package/dist/prepare-BAtWufvm.mjs +99 -0
- package/dist/preset-D4I73kT4.mjs +221 -0
- package/dist/project-TqORyHn8.mjs +72 -0
- package/dist/project-cmd-B7lQp3F3.mjs +67 -0
- package/dist/project-slug-CKam8lF9.mjs +11 -0
- package/dist/project-tsconfig-DfkESbDL.mjs +63 -0
- package/dist/protocol-BWzXs2A2.d.mts +34 -0
- package/dist/providers-B3aMxWzP.mjs +67 -0
- package/dist/resolve-project-Br5BR03U.mjs +29 -0
- package/dist/rollback-gyC59l7U.mjs +92 -0
- package/dist/route-types-DReF1gUY.mjs +255 -0
- package/dist/routes-stub.d.mts +55 -0
- package/dist/routes-stub.mjs +1 -0
- package/dist/runner-6Ep3fNQu.mjs +123 -0
- package/dist/runner-pg-D0wWHYnr.mjs +57 -0
- package/dist/runtime/ai.d.mts +127 -0
- package/dist/runtime/ai.mjs +348 -0
- package/dist/runtime/auth-client-react.d.mts +8 -0
- package/dist/runtime/auth-client-react.mjs +6 -0
- package/dist/runtime/auth-client-solid.d.mts +8 -0
- package/dist/runtime/auth-client-solid.mjs +6 -0
- package/dist/runtime/auth-client-svelte.d.mts +8 -0
- package/dist/runtime/auth-client-svelte.mjs +6 -0
- package/dist/runtime/auth-client-vue.d.mts +8 -0
- package/dist/runtime/auth-client-vue.mjs +6 -0
- package/dist/runtime/auth-client.d.mts +8 -0
- package/dist/runtime/auth-client.mjs +6 -0
- package/dist/runtime/auth.d.mts +2 -0
- package/dist/runtime/auth.mjs +22 -0
- package/dist/runtime/better-auth-pg.d.mts +11 -0
- package/dist/runtime/better-auth-pg.mjs +51 -0
- package/dist/runtime/better-auth.d.mts +11 -0
- package/dist/runtime/better-auth.mjs +33 -0
- package/dist/runtime/client.d.mts +6 -0
- package/dist/runtime/client.mjs +5 -0
- package/dist/runtime/db-pg.d.mts +2 -0
- package/dist/runtime/db-pg.mjs +1 -0
- package/dist/runtime/db.d.mts +17 -0
- package/dist/runtime/db.mjs +30 -0
- package/dist/runtime/drizzle-arktype.d.mts +1 -0
- package/dist/runtime/drizzle-arktype.mjs +2 -0
- package/dist/runtime/drizzle-valibot.d.mts +1 -0
- package/dist/runtime/drizzle-valibot.mjs +2 -0
- package/dist/runtime/drizzle-zod.d.mts +1 -0
- package/dist/runtime/drizzle-zod.mjs +2 -0
- package/dist/runtime/env-helpers.d.mts +2 -0
- package/dist/runtime/env-helpers.mjs +173 -0
- package/dist/runtime/env-public-client.d.mts +22 -0
- package/dist/runtime/env-public-client.mjs +54 -0
- package/dist/runtime/env-public.d.mts +143 -0
- package/dist/runtime/env-public.mjs +366 -0
- package/dist/runtime/env.d.mts +13 -0
- package/dist/runtime/env.mjs +51 -0
- package/dist/runtime/fetch-stream.d.mts +51 -0
- package/dist/runtime/fetch-stream.mjs +81 -0
- package/dist/runtime/fetch.d.mts +59 -0
- package/dist/runtime/fetch.mjs +18 -0
- package/dist/runtime/handler.d.mts +3 -0
- package/dist/runtime/handler.mjs +85 -0
- package/dist/runtime/isr.d.mts +26 -0
- package/dist/runtime/isr.mjs +43 -0
- package/dist/runtime/kv.d.mts +48 -0
- package/dist/runtime/kv.mjs +106 -0
- package/dist/runtime/log.d.mts +24 -0
- package/dist/runtime/log.mjs +31 -0
- package/dist/runtime/migration-handler-pg.d.mts +6 -0
- package/dist/runtime/migration-handler-pg.mjs +85 -0
- package/dist/runtime/migration-handler.d.mts +19 -0
- package/dist/runtime/migration-handler.mjs +92 -0
- package/dist/runtime/queues.d.mts +7 -0
- package/dist/runtime/queues.mjs +8 -0
- package/dist/runtime/remote/binding-handler.d.mts +15 -0
- package/dist/runtime/remote/binding-handler.mjs +208 -0
- package/dist/runtime/remote/index.d.mts +8 -0
- package/dist/runtime/remote/index.mjs +461 -0
- package/dist/runtime/response.d.mts +14 -0
- package/dist/runtime/response.mjs +30 -0
- package/dist/runtime/sandbox.d.mts +17 -0
- package/dist/runtime/sandbox.mjs +19 -0
- package/dist/runtime/schema-d1.d.mts +1 -0
- package/dist/runtime/schema-d1.mjs +2 -0
- package/dist/runtime/schema-pg.d.mts +1 -0
- package/dist/runtime/schema-pg.mjs +2 -0
- package/dist/runtime/seed.d.mts +30 -0
- package/dist/runtime/seed.mjs +6 -0
- package/dist/runtime/storage.d.mts +7 -0
- package/dist/runtime/storage.mjs +14 -0
- package/dist/runtime/validator.d.mts +2 -0
- package/dist/runtime/validator.mjs +72 -0
- package/dist/runtime/ws-server.d.mts +26 -0
- package/dist/runtime/ws-server.mjs +296 -0
- package/dist/runtime/ws.d.mts +123 -0
- package/dist/runtime/ws.mjs +103 -0
- package/dist/scan-Ba4hFwlH.mjs +324 -0
- package/dist/scan-C6HMEIdW.mjs +318 -0
- package/dist/secret-CeRSukgM.mjs +109 -0
- package/dist/skills-ipldjlKE.mjs +62 -0
- package/dist/standard-schema-9CRjx-uR.d.mts +42 -0
- package/dist/subcommand-prompt-BKjuNAPb.mjs +349 -0
- package/dist/sveltekit.d.mts +20 -0
- package/dist/sveltekit.mjs +61 -0
- package/dist/types-mHOEwpW4.d.mts +57 -0
- package/dist/validate-CaMavMxu.mjs +146 -0
- package/dist/yarn-pnp-BFqMV_bl.mjs +196 -0
- package/getting-started-prompt.txt +26 -0
- package/package.json +322 -30
- package/schema.json +364 -0
- package/skills/migrate-vite-cloudflare-to-void/SKILL.md +175 -0
- package/skills/void/SKILL.md +75 -0
- package/skills/void/command/void.md +7 -0
- package/skills/void/docs/guide/ai.md +235 -0
- package/skills/void/docs/guide/app-types.md +103 -0
- package/skills/void/docs/guide/auth.md +257 -0
- package/skills/void/docs/guide/database/d1.md +106 -0
- package/skills/void/docs/guide/database/postgresql.md +106 -0
- package/skills/void/docs/guide/database.md +418 -0
- package/skills/void/docs/guide/deployment.md +98 -0
- package/skills/void/docs/guide/edge/headers.md +79 -0
- package/skills/void/docs/guide/edge/prerendering.md +83 -0
- package/skills/void/docs/guide/edge/redirects.md +116 -0
- package/skills/void/docs/guide/edge/revalidation.md +131 -0
- package/skills/void/docs/guide/edge/rewrites.md +354 -0
- package/skills/void/docs/guide/edge/static-assets.md +72 -0
- package/skills/void/docs/guide/env-vars.md +298 -0
- package/skills/void/docs/guide/index.md +80 -0
- package/skills/void/docs/guide/jobs.md +91 -0
- package/skills/void/docs/guide/kv.md +107 -0
- package/skills/void/docs/guide/pages-routing/actions-and-forms.md +419 -0
- package/skills/void/docs/guide/pages-routing/head.md +130 -0
- package/skills/void/docs/guide/pages-routing/islands.md +405 -0
- package/skills/void/docs/guide/pages-routing/layouts.md +362 -0
- package/skills/void/docs/guide/pages-routing/loaders.md +267 -0
- package/skills/void/docs/guide/pages-routing/markdown.md +625 -0
- package/skills/void/docs/guide/pages-routing/overview.md +236 -0
- package/skills/void/docs/guide/pages-routing/view-transitions.md +140 -0
- package/skills/void/docs/guide/queues.md +140 -0
- package/skills/void/docs/guide/quickstart.md +233 -0
- package/skills/void/docs/guide/remote-dev.md +67 -0
- package/skills/void/docs/guide/sandboxes.md +82 -0
- package/skills/void/docs/guide/server-routing.md +246 -0
- package/skills/void/docs/guide/ssg.md +74 -0
- package/skills/void/docs/guide/ssr.md +105 -0
- package/skills/void/docs/guide/storage.md +67 -0
- package/skills/void/docs/guide/type-safety.md +179 -0
- package/skills/void/docs/guide/typed-fetch.md +113 -0
- package/skills/void/docs/guide/websockets.md +190 -0
- package/skills/void/docs/index.md +48 -0
- package/skills/void/docs/integrations/agents.md +84 -0
- package/skills/void/docs/integrations/cloudflare.md +284 -0
- package/skills/void/docs/integrations/frameworks/analog.md +182 -0
- package/skills/void/docs/integrations/frameworks/astro.md +197 -0
- package/skills/void/docs/integrations/frameworks/nuxt.md +164 -0
- package/skills/void/docs/integrations/frameworks/overview.md +136 -0
- package/skills/void/docs/integrations/frameworks/react-router.md +137 -0
- package/skills/void/docs/integrations/frameworks/sveltekit.md +191 -0
- package/skills/void/docs/integrations/frameworks/tanstack-start.md +140 -0
- package/skills/void/docs/integrations/hono.md +97 -0
- package/skills/void/docs/integrations/nodejs-bun-deno.md +210 -0
- package/skills/void/docs/node_modules/@iconify/vue/README.md +408 -0
- package/skills/void/docs/node_modules/@iconify/vue/offline/readme.md +5 -0
- package/skills/void/docs/node_modules/@voidzero-dev/vitepress-theme/README.md +103 -0
- package/skills/void/docs/node_modules/oxc-minify/README.md +78 -0
- package/skills/void/docs/node_modules/reka-ui/README.md +80 -0
- package/skills/void/docs/node_modules/vitepress/README.md +28 -0
- package/skills/void/docs/node_modules/vitepress/template/api-examples.md +49 -0
- package/skills/void/docs/node_modules/vitepress/template/index.md +28 -0
- package/skills/void/docs/node_modules/vitepress/template/markdown-examples.md +85 -0
- package/skills/void/docs/node_modules/vitepress-plugin-group-icons/README.md +101 -0
- package/skills/void/docs/node_modules/void/AGENTS.md +204 -0
- package/skills/void/docs/node_modules/void/AGENT_PROMPT.md +15 -0
- package/skills/void/docs/node_modules/void/README.md +89 -0
- package/skills/void/docs/node_modules/void/node_modules/@clack/prompts/CHANGELOG.md +591 -0
- package/skills/void/docs/node_modules/void/node_modules/@clack/prompts/README.md +375 -0
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/sandbox/README.md +174 -0
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/vite-plugin/README.md +37 -0
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/workers-types/README.md +135 -0
- package/skills/void/docs/node_modules/void/node_modules/@electric-sql/pglite/README.md +189 -0
- package/skills/void/docs/node_modules/void/node_modules/@hono/oauth-providers/CHANGELOG.md +143 -0
- package/skills/void/docs/node_modules/void/node_modules/@hono/oauth-providers/README.md +1272 -0
- package/skills/void/docs/node_modules/void/node_modules/@napi-rs/keyring/README.md +19 -0
- package/skills/void/docs/node_modules/void/node_modules/@types/better-sqlite3/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@types/node/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@types/pg/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@typescript/native-preview/README.md +22 -0
- package/skills/void/docs/node_modules/void/node_modules/@typescript/native-preview/vendor/vscode-jsonrpc/README.md +69 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/README.md +152 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@shikijs/engine-javascript/README.md +9 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@shikijs/transformers/README.md +9 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@types/node/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/gray-matter/CHANGELOG.md +24 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/gray-matter/README.md +565 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-exit/README.md +124 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-anchor/README.md +600 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-attrs/README.md +386 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-container/README.md +95 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-emoji/README.md +101 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/pathe/README.md +73 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/shiki/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/tinyglobby/README.md +25 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/tsdown/README.md +55 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite/LICENSE.md +2230 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite/README.md +20 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vue/README.md +58 -0
- package/skills/void/docs/node_modules/void/node_modules/arktype/README.md +165 -0
- package/skills/void/docs/node_modules/void/node_modules/better-auth/LICENSE.md +20 -0
- package/skills/void/docs/node_modules/void/node_modules/better-auth/README.md +32 -0
- package/skills/void/docs/node_modules/void/node_modules/better-sqlite3/README.md +99 -0
- package/skills/void/docs/node_modules/void/node_modules/blake3-jit/README.md +108 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-arktype/README.md +51 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-kit/README.md +79 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-orm/README.md +44 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-valibot/README.md +51 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-zod/README.md +65 -0
- package/skills/void/docs/node_modules/void/node_modules/es-module-lexer/README.md +390 -0
- package/skills/void/docs/node_modules/void/node_modules/estree-walker/README.md +48 -0
- package/skills/void/docs/node_modules/void/node_modules/hono/README.md +85 -0
- package/skills/void/docs/node_modules/void/node_modules/ignore/README.md +452 -0
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/CHANGELOG.md +76 -0
- package/{LICENSE → skills/void/docs/node_modules/void/node_modules/jsonc-parser/LICENSE.md} +21 -21
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/README.md +364 -0
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/SECURITY.md +41 -0
- package/skills/void/docs/node_modules/void/node_modules/magic-string/README.md +325 -0
- package/skills/void/docs/node_modules/void/node_modules/ofetch/README.md +398 -0
- package/skills/void/docs/node_modules/void/node_modules/pathe/README.md +73 -0
- package/skills/void/docs/node_modules/void/node_modules/pg/README.md +95 -0
- package/skills/void/docs/node_modules/void/node_modules/pglite-server/LICENSE.md +21 -0
- package/skills/void/docs/node_modules/void/node_modules/pglite-server/README.md +135 -0
- package/skills/void/docs/node_modules/void/node_modules/picocolors/README.md +21 -0
- package/skills/void/docs/node_modules/void/node_modules/tinyglobby/README.md +25 -0
- package/skills/void/docs/node_modules/void/node_modules/tsdown/README.md +55 -0
- package/skills/void/docs/node_modules/void/node_modules/valibot/LICENSE.md +9 -0
- package/skills/void/docs/node_modules/void/node_modules/valibot/README.md +94 -0
- package/skills/void/docs/node_modules/void/node_modules/vite/LICENSE.md +2230 -0
- package/skills/void/docs/node_modules/void/node_modules/vite/README.md +20 -0
- package/skills/void/docs/node_modules/void/node_modules/wrangler/README.md +63 -0
- package/skills/void/docs/node_modules/void/node_modules/zod/README.md +191 -0
- package/skills/void/docs/node_modules/void/skills/migrate-vite-cloudflare-to-void/SKILL.md +175 -0
- package/skills/void/docs/node_modules/void/skills/void/SKILL.md +75 -0
- package/skills/void/docs/node_modules/void/skills/void/command/void.md +7 -0
- package/skills/void/docs/reference/api.md +917 -0
- package/skills/void/docs/reference/cli.md +561 -0
- package/skills/void/docs/reference/config.md +408 -0
- package/skills/void/docs/reference/resource-inference.md +149 -0
- package/skills/void/docs/reference/structure.md +176 -0
- package/.npmignore +0 -29
- package/.travis.yml +0 -9
- package/favicon.ico +0 -0
- package/index.js +0 -14
- package/lib/Job.js +0 -150
- package/lib/Void.js +0 -99
- package/lib/scan.js +0 -19
- package/test/credentials.js +0 -20
- package/test/job.js +0 -64
- package/test/static/dir1/test6.html +0 -0
- package/test/static/dir2/test7.html +0 -0
- package/test/static/dir2/test8.html +0 -0
- package/test/static/dir2/test9.html +0 -0
- package/test/static/test1.html +0 -0
- package/test/static/test2.html +0 -0
- package/test/static/test3.html +0 -0
- package/test/void.js +0 -31
- /package/{test/static/dir1/test4.html → skills/void/docs/integrations/auth-providers.md} +0 -0
- /package/{test/static/dir1/test5.html → skills/void/docs/integrations/payment-processors.md} +0 -0
|
@@ -0,0 +1,917 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# API Reference
|
|
6
|
+
|
|
7
|
+
This page is the source of truth for public `void` exports. Use it when you already know what feature you want and need the exact import, signature, or return type.
|
|
8
|
+
|
|
9
|
+
## Plugin
|
|
10
|
+
|
|
11
|
+
### `voidPlugin(options?)`
|
|
12
|
+
|
|
13
|
+
Named export from `"void"`. Returns an array of Vite plugins that set up file-based routing, migration support, and the Cloudflare Workers runtime. Application-level configuration is read from [`void.json`](./config.md); the optional `options` object controls Vite/Cloudflare plugin behavior.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { voidPlugin } from 'void';
|
|
17
|
+
|
|
18
|
+
export default defineConfig({
|
|
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
|
+
## Handlers
|
|
29
|
+
|
|
30
|
+
Imported from `"void"` or `"void/handler"`.
|
|
31
|
+
|
|
32
|
+
### `defineHandler(handler)`
|
|
33
|
+
|
|
34
|
+
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.
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { defineHandler } from 'void';
|
|
38
|
+
|
|
39
|
+
export const GET = defineHandler((c) => {
|
|
40
|
+
return { message: 'hello' };
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Signature:**
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
function defineHandler<R>(handler: (c: CloudContext) => R): TypedHandler<{}, R>;
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### `defineHandler(middleware..., handler)`
|
|
51
|
+
|
|
52
|
+
Composes up to 5 per-route middleware with a final handler. Middleware runs in order before the handler.
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
export const GET = defineHandler(authMiddleware, rateLimiter, (c) => {
|
|
56
|
+
return { ok: true };
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### `defineHandler.withValidator(validators)`
|
|
61
|
+
|
|
62
|
+
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.
|
|
63
|
+
|
|
64
|
+
Validated input is passed as the second argument to the handler.
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { defineHandler } from 'void';
|
|
68
|
+
import * as v from 'valibot';
|
|
69
|
+
|
|
70
|
+
export const POST = defineHandler.withValidator({
|
|
71
|
+
body: v.object({
|
|
72
|
+
name: v.pipe(v.string(), v.minLength(1)),
|
|
73
|
+
email: v.pipe(v.string(), v.email()),
|
|
74
|
+
}),
|
|
75
|
+
})((c, { body }) => {
|
|
76
|
+
return { received: body.name };
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Signature:**
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
function withValidator<V extends ValidatorSlots>(
|
|
84
|
+
validators: V,
|
|
85
|
+
): <R>(handler: (c: CloudContext, input: HandlerInput<V>) => R) => TypedHandler<V, R>;
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Type: `ValidatorSlots`**
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
interface ValidatorSlots {
|
|
92
|
+
body?: StandardSchemaV1;
|
|
93
|
+
query?: StandardSchemaV1;
|
|
94
|
+
params?: StandardSchemaV1;
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Type: `HandlerInput<V>`**
|
|
99
|
+
|
|
100
|
+
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.
|
|
101
|
+
|
|
102
|
+
### `defineMiddleware(handler)`
|
|
103
|
+
|
|
104
|
+
Type-safe wrapper for Hono middleware. At runtime, returns the function unchanged.
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import { defineMiddleware } from 'void';
|
|
108
|
+
|
|
109
|
+
export default defineMiddleware(async (c, next) => {
|
|
110
|
+
console.log(`${c.req.method} ${c.req.path}`);
|
|
111
|
+
await next();
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Signature:**
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
function defineMiddleware(handler: MiddlewareHandler<CloudEnv>): MiddlewareHandler<CloudEnv>;
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### `defineScheduled(handler)`
|
|
122
|
+
|
|
123
|
+
Wraps a Cloudflare [Scheduled handler](https://developers.cloudflare.com/workers/runtime-apis/handlers/scheduled/) with type inference.
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
import { defineScheduled } from 'void';
|
|
127
|
+
|
|
128
|
+
export default defineScheduled(async (controller, env, ctx) => {
|
|
129
|
+
const { results } = await env.DB.prepare('SELECT * FROM stale').all();
|
|
130
|
+
// ...
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Signature:**
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
function defineScheduled(
|
|
138
|
+
handler: (
|
|
139
|
+
controller: ScheduledController,
|
|
140
|
+
env: CloudEnv['Bindings'],
|
|
141
|
+
ctx: ExecutionContext,
|
|
142
|
+
) => unknown | Promise<unknown>,
|
|
143
|
+
): ScheduledFn;
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### `defineQueue<T>(handler)`
|
|
147
|
+
|
|
148
|
+
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.
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
import { defineQueue } from 'void';
|
|
152
|
+
|
|
153
|
+
export default defineQueue<{ to: string; subject: string }>(async (batch, env) => {
|
|
154
|
+
for (const msg of batch.messages) {
|
|
155
|
+
console.log(`Send to ${msg.body.to}: ${msg.body.subject}`);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Signature:**
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
function defineQueue<T>(
|
|
164
|
+
handler: (batch: QueueBatch<T>, env: CloudEnv['Bindings']) => void | Promise<void>,
|
|
165
|
+
): QueueFn;
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### `defineRender(handler)`
|
|
169
|
+
|
|
170
|
+
Wraps an SSR render entry. The second argument provides pre-built `<head>` and `<body>` asset tags for injecting client scripts and styles.
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
import { defineRender } from "void";
|
|
174
|
+
import { renderToString } from "react-dom/server";
|
|
175
|
+
|
|
176
|
+
export default defineRender((c, assetTags) => {
|
|
177
|
+
const html = renderToString(<App />);
|
|
178
|
+
return c.html(`<!DOCTYPE html>
|
|
179
|
+
<html><head>${assetTags.css}${assetTags.preloads}</head>
|
|
180
|
+
<body><div id="root">${html}</div>${assetTags.body}</body></html>`);
|
|
181
|
+
});
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Signature:**
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
function defineRender(
|
|
188
|
+
handler: (c: CloudContext, assetTags: RenderAssetTags) => Response | Promise<Response>,
|
|
189
|
+
): RenderFn;
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Type: `RenderAssetTags`**
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
interface RenderAssetTags {
|
|
196
|
+
head: string; // Script and style tags for <head>
|
|
197
|
+
body: string; // Script tags for before </body>
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### `defineHead<P>(handler)`
|
|
202
|
+
|
|
203
|
+
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.
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
import { defineHandler, defineHead } from 'void';
|
|
207
|
+
import type { InferProps } from 'void';
|
|
208
|
+
|
|
209
|
+
export type Props = InferProps<typeof loader>;
|
|
210
|
+
|
|
211
|
+
export const loader = defineHandler(async (c) => {
|
|
212
|
+
const post = await getPost(c.req.param('slug'));
|
|
213
|
+
return { post };
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
export const head = defineHead<Props>((c, props) => {
|
|
217
|
+
return {
|
|
218
|
+
title: props.post.title,
|
|
219
|
+
meta: [
|
|
220
|
+
{ name: 'description', content: props.post.excerpt },
|
|
221
|
+
{ property: 'og:title', content: props.post.title },
|
|
222
|
+
],
|
|
223
|
+
};
|
|
224
|
+
});
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
**Signature:**
|
|
228
|
+
|
|
229
|
+
```ts
|
|
230
|
+
function defineHead<P = Record<string, unknown>>(
|
|
231
|
+
handler: (c: CloudContext, props: P) => HeadDescriptor | undefined,
|
|
232
|
+
): (c: CloudContext, props: P) => HeadDescriptor | undefined;
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Rewrites
|
|
236
|
+
|
|
237
|
+
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.json`](./config.md#routing).
|
|
238
|
+
|
|
239
|
+
### `c.rewrite(destination)`
|
|
240
|
+
|
|
241
|
+
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.
|
|
242
|
+
|
|
243
|
+
`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.
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
import { defineHandler } from 'void';
|
|
247
|
+
|
|
248
|
+
export const GET = defineHandler((c) => {
|
|
249
|
+
const locale = c.req.header('accept-language')?.startsWith('de') ? 'de' : 'en';
|
|
250
|
+
return c.rewrite(`/${locale}${new URL(c.req.url).pathname}`);
|
|
251
|
+
});
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Signature:**
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
interface CloudContext {
|
|
258
|
+
rewrite(destination: RewriteDestination): Promise<Response>;
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**Caveats:**
|
|
263
|
+
|
|
264
|
+
- `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.
|
|
265
|
+
- 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.
|
|
266
|
+
- Middleware re-runs on every rewrite hop. Guard side-effects with [`c.isRewritten()`](#c-originalurl-c-isrewritten).
|
|
267
|
+
- Client-side SPA navigation via `Link` does not trigger server rewrites; only full HTTP requests do.
|
|
268
|
+
- [ISR](../guide/edge/revalidation.md) cache keys follow the rewritten path, not the original URL.
|
|
269
|
+
|
|
270
|
+
### `c.originalUrl()` / `c.isRewritten()`
|
|
271
|
+
|
|
272
|
+
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.
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
import { defineMiddleware } from 'void';
|
|
276
|
+
|
|
277
|
+
export default defineMiddleware(async (c, next) => {
|
|
278
|
+
if (!c.isRewritten()) {
|
|
279
|
+
// Only log the user-visible request, not internal rewrite hops.
|
|
280
|
+
console.log(`${c.req.method} ${c.req.path}`);
|
|
281
|
+
}
|
|
282
|
+
await next();
|
|
283
|
+
});
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
**Signature:**
|
|
287
|
+
|
|
288
|
+
```ts
|
|
289
|
+
interface CloudContext {
|
|
290
|
+
originalUrl(): URL | null;
|
|
291
|
+
isRewritten(): boolean;
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### `RewriteDestination`
|
|
296
|
+
|
|
297
|
+
```ts
|
|
298
|
+
import type { RewriteDestination } from 'void/routes';
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
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:
|
|
302
|
+
|
|
303
|
+
- The parameter type of [`c.rewrite()`](#c-rewrite-destination).
|
|
304
|
+
- The type of `destination` entries in `routing.rewrites` and `routing.fallbacks` in [`void.json`](./config.md#routing).
|
|
305
|
+
|
|
306
|
+
Like [`RouteMap`](#routemap), `RewriteDestination` lives in the virtual `void/routes` module and is refreshed whenever routes change.
|
|
307
|
+
|
|
308
|
+
## Auth
|
|
309
|
+
|
|
310
|
+
Imported from `"void"` or `"void/auth"`. Client-side helpers imported from `"void/client"`.
|
|
311
|
+
|
|
312
|
+
### `defineAuth(config)`
|
|
313
|
+
|
|
314
|
+
Advanced escape hatch for customizing Void's Better Auth config.
|
|
315
|
+
|
|
316
|
+
```ts
|
|
317
|
+
import { defineAuth } from 'void/auth';
|
|
318
|
+
|
|
319
|
+
export default defineAuth(({ defaults }) => ({
|
|
320
|
+
...defaults,
|
|
321
|
+
trustedOrigins: ['https://example.com'],
|
|
322
|
+
}));
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
**Signature:**
|
|
326
|
+
|
|
327
|
+
```ts
|
|
328
|
+
function defineAuth(config: VoidAuthConfig): VoidAuthConfig;
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### `getUser()`
|
|
332
|
+
|
|
333
|
+
Returns the current authenticated user from AsyncLocalStorage, or `null` when no user is present.
|
|
334
|
+
|
|
335
|
+
```ts
|
|
336
|
+
import { getUser } from 'void/auth';
|
|
337
|
+
|
|
338
|
+
const user = getUser();
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
**Signature:**
|
|
342
|
+
|
|
343
|
+
```ts
|
|
344
|
+
function getUser(): AuthUser | null;
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### `getSession()`
|
|
348
|
+
|
|
349
|
+
Returns the current Better Auth request state, or `null`.
|
|
350
|
+
|
|
351
|
+
```ts
|
|
352
|
+
import { getSession } from 'void/auth';
|
|
353
|
+
|
|
354
|
+
const state = getSession();
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
**Signature:**
|
|
358
|
+
|
|
359
|
+
```ts
|
|
360
|
+
function getSession(): AuthState | null;
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
### `requireAuth(c)`
|
|
364
|
+
|
|
365
|
+
Extracts the authenticated user from the request context. Throws a 401 `HTTPException` if no session is present.
|
|
366
|
+
|
|
367
|
+
```ts
|
|
368
|
+
import { defineHandler } from 'void';
|
|
369
|
+
import { requireAuth } from 'void/auth';
|
|
370
|
+
|
|
371
|
+
export const GET = defineHandler((c) => {
|
|
372
|
+
const user = requireAuth(c);
|
|
373
|
+
return { email: user.email };
|
|
374
|
+
});
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
**Signature:**
|
|
378
|
+
|
|
379
|
+
```ts
|
|
380
|
+
function requireAuth(c: CloudContext): AuthUser;
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### `AuthUser`
|
|
384
|
+
|
|
385
|
+
Better Auth user shape re-exported by Void.
|
|
386
|
+
|
|
387
|
+
```ts
|
|
388
|
+
interface AuthUser {
|
|
389
|
+
id: string;
|
|
390
|
+
email: string;
|
|
391
|
+
emailVerified: boolean;
|
|
392
|
+
name: string;
|
|
393
|
+
image?: string | null;
|
|
394
|
+
createdAt: Date;
|
|
395
|
+
updatedAt: Date;
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### `AuthSession`
|
|
400
|
+
|
|
401
|
+
Better Auth session shape re-exported by Void.
|
|
402
|
+
|
|
403
|
+
```ts
|
|
404
|
+
interface AuthSession {
|
|
405
|
+
id: string;
|
|
406
|
+
token: string;
|
|
407
|
+
userId: string;
|
|
408
|
+
expiresAt: Date;
|
|
409
|
+
createdAt: Date;
|
|
410
|
+
updatedAt: Date;
|
|
411
|
+
ipAddress?: string | null;
|
|
412
|
+
userAgent?: string | null;
|
|
413
|
+
}
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### `AuthState`
|
|
417
|
+
|
|
418
|
+
Combined authenticated request state:
|
|
419
|
+
|
|
420
|
+
```ts
|
|
421
|
+
interface AuthState {
|
|
422
|
+
user: AuthUser;
|
|
423
|
+
session: AuthSession;
|
|
424
|
+
}
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### `auth`
|
|
428
|
+
|
|
429
|
+
Imported from `"void/client"`. This is a ready-to-use Better Auth client instance preconfigured with `basePath: "/api/auth"`.
|
|
430
|
+
|
|
431
|
+
```ts
|
|
432
|
+
import { auth } from 'void/client';
|
|
433
|
+
|
|
434
|
+
await auth.signIn.email({ email, password });
|
|
435
|
+
await auth.signOut();
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
The exact client methods come from Better Auth. In pages apps, Void automatically chooses the framework-specific Better Auth client package when available.
|
|
439
|
+
|
|
440
|
+
### `createAuthClient`
|
|
441
|
+
|
|
442
|
+
Imported from `"void/client"`. Re-export of Better Auth's `createAuthClient` for advanced usage.
|
|
443
|
+
|
|
444
|
+
```ts
|
|
445
|
+
import { createAuthClient } from 'void/client';
|
|
446
|
+
|
|
447
|
+
const auth = createAuthClient({ basePath: '/api/auth' });
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
## Fetch Client
|
|
451
|
+
|
|
452
|
+
Imported from `"void/client"`.
|
|
453
|
+
|
|
454
|
+
### `fetch(path, options?)`
|
|
455
|
+
|
|
456
|
+
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`.
|
|
457
|
+
|
|
458
|
+
```ts
|
|
459
|
+
import { fetch } from 'void/client';
|
|
460
|
+
|
|
461
|
+
// Types are fully inferred from your route handlers
|
|
462
|
+
const users = await fetch('/api/users');
|
|
463
|
+
const user = await fetch('/api/users/:id', {
|
|
464
|
+
params: { id: '1' },
|
|
465
|
+
});
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
**Signature:**
|
|
469
|
+
|
|
470
|
+
```ts
|
|
471
|
+
function fetch<P extends keyof RouteMap, M extends MethodsOf<P>>(
|
|
472
|
+
path: P,
|
|
473
|
+
options?: FetchOptions<P, M>,
|
|
474
|
+
): Promise<OutputOf<P, M>>;
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
**Options:**
|
|
478
|
+
|
|
479
|
+
| Option | Type | Description |
|
|
480
|
+
| --------- | ------------------------ | ---------------------------------------------------------- |
|
|
481
|
+
| `method` | `string` | HTTP method. Defaults to `"GET"`. |
|
|
482
|
+
| `body` | `unknown` | Request body (auto-serialized as JSON). |
|
|
483
|
+
| `query` | `Record<string, string>` | Query string parameters. |
|
|
484
|
+
| `params` | `Record<string, string>` | URL path parameters (`:id` segments). |
|
|
485
|
+
| `headers` | `HeadersInit` | Additional request headers. |
|
|
486
|
+
| `signal` | `AbortSignal` | Abort signal. |
|
|
487
|
+
| `baseURL` | `string` | Base URL prepended to the path. Useful for external calls. |
|
|
488
|
+
| `retry` | `number` | Number of retry attempts (ofetch default: 1 for GET). |
|
|
489
|
+
| `timeout` | `number` | Request timeout in milliseconds. |
|
|
490
|
+
|
|
491
|
+
Returns the parsed JSON response body, or `undefined` for 204 responses. Throws `FetchError` on non-2xx responses.
|
|
492
|
+
|
|
493
|
+
### `FetchError`
|
|
494
|
+
|
|
495
|
+
Error class thrown by `fetch` on non-2xx responses.
|
|
496
|
+
|
|
497
|
+
```ts
|
|
498
|
+
import { fetch, FetchError } from 'void/client';
|
|
499
|
+
|
|
500
|
+
try {
|
|
501
|
+
await fetch('/api/users/:id', { params: { id: '999' } });
|
|
502
|
+
} catch (e) {
|
|
503
|
+
if (e instanceof FetchError) {
|
|
504
|
+
console.log(e.status); // 404
|
|
505
|
+
console.log(e.response); // raw Response
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
**Properties:**
|
|
511
|
+
|
|
512
|
+
| Property | Type | Description |
|
|
513
|
+
| ---------- | ---------- | ------------------------------------ |
|
|
514
|
+
| `status` | `number` | HTTP status code. |
|
|
515
|
+
| `response` | `Response` | The raw `Response` object. |
|
|
516
|
+
| `data` | `unknown` | Parsed response body (if available). |
|
|
517
|
+
|
|
518
|
+
### Differences from Native `fetch`
|
|
519
|
+
|
|
520
|
+
The typed client is built on [ofetch](https://github.com/unjs/ofetch) with a typed route layer on top. Key differences from native `fetch`:
|
|
521
|
+
|
|
522
|
+
| Behavior | Native `fetch` | `void/client` `fetch` |
|
|
523
|
+
| ---------------------- | ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
524
|
+
| **Return type** | `Promise<Response>`, so you call `.json()` yourself | `Promise<T>`, which auto-parses JSON and returns the typed result directly (`undefined` for `204`) |
|
|
525
|
+
| **Error handling** | Resolves on any HTTP status; you check `response.ok` | Throws `FetchError` on non-2xx responses |
|
|
526
|
+
| **URL construction** | Raw URL string | Route path with `:param` interpolation from `options.params` + query string from `options.query` |
|
|
527
|
+
| **Body serialization** | Manual `JSON.stringify()` + `Content-Type` header | Auto-serializes `options.body` as JSON and sets `Content-Type: application/json` |
|
|
528
|
+
| **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. |
|
|
529
|
+
| **Retry** | None | Auto-retries on 408, 429, and 5xx (configurable via `retry` option) |
|
|
530
|
+
| **Timeout** | None | Configurable via `timeout` option |
|
|
531
|
+
|
|
532
|
+
`headers` and `signal` are passed through to the underlying fetch unchanged.
|
|
533
|
+
|
|
534
|
+
## Database
|
|
535
|
+
|
|
536
|
+
Imported from `"void/db"`. The `db` export is a [Drizzle ORM](https://orm.drizzle.team) instance for [Cloudflare D1](https://developers.cloudflare.com/d1/). See the [Database guide](../guide/database.md) for usage and the [Drizzle docs](https://orm.drizzle.team/docs/select) for the full query API.
|
|
537
|
+
|
|
538
|
+
### `db`
|
|
539
|
+
|
|
540
|
+
Default Drizzle D1 instance, pre-wired with the `env.DB` binding and your schema from `db/schema.ts`.
|
|
541
|
+
|
|
542
|
+
```ts
|
|
543
|
+
import { db } from 'void/db';
|
|
544
|
+
import { users } from '@schema';
|
|
545
|
+
|
|
546
|
+
const allUsers = await db.select().from(users).all();
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
When the Void plugin is active, `void/db` is served as a virtual module that auto-wires the D1 binding with your schema. The published npm fallback uses a lazy proxy that resolves the `DB` binding at first access.
|
|
550
|
+
|
|
551
|
+
### `createDb(database)`
|
|
552
|
+
|
|
553
|
+
Creates a Drizzle D1 instance from a specific D1 binding. Use this when you have multiple D1 databases or need a non-default binding.
|
|
554
|
+
|
|
555
|
+
```ts
|
|
556
|
+
import { createDb } from 'void/db';
|
|
557
|
+
import { env } from 'cloudflare:workers';
|
|
558
|
+
|
|
559
|
+
const db = createDb(env.MY_OTHER_DB);
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
**Signature:**
|
|
563
|
+
|
|
564
|
+
```ts
|
|
565
|
+
function createDb(d1: D1Database): DrizzleD1Database;
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
### Query Operators
|
|
569
|
+
|
|
570
|
+
`void/db` re-exports commonly used [Drizzle operators](https://orm.drizzle.team/docs/operators) so you never need to depend on `drizzle-orm` directly:
|
|
571
|
+
|
|
572
|
+
```ts
|
|
573
|
+
import { db, eq, and, or, desc, like, inArray, sql } from 'void/db';
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
**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`.
|
|
577
|
+
|
|
578
|
+
## Seeding
|
|
579
|
+
|
|
580
|
+
Imported from `"void/seed"`.
|
|
581
|
+
|
|
582
|
+
### `defineSeed(fn)`
|
|
583
|
+
|
|
584
|
+
Identity helper for programmatic seed modules used by `void db seed`.
|
|
585
|
+
|
|
586
|
+
```ts
|
|
587
|
+
import { defineSeed } from 'void/seed';
|
|
588
|
+
|
|
589
|
+
export default defineSeed<typeof import('./schema')>(async ({ db, schema }) => {
|
|
590
|
+
await db.insert(schema.users).values([
|
|
591
|
+
{ name: 'Alice', email: 'alice@example.com' },
|
|
592
|
+
{ name: 'Bob', email: 'bob@example.com' },
|
|
593
|
+
]);
|
|
594
|
+
});
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
The callback receives:
|
|
598
|
+
|
|
599
|
+
- `dialect`: `"sqlite"` or `"postgresql"`
|
|
600
|
+
- `db`: a local Drizzle instance for the active dialect
|
|
601
|
+
- `schema`: the exports from `db/schema.ts` or `db/schema/`
|
|
602
|
+
|
|
603
|
+
Seed modules can export either `default` or a named `seed` function.
|
|
604
|
+
|
|
605
|
+
## Types
|
|
606
|
+
|
|
607
|
+
### `CloudContext`
|
|
608
|
+
|
|
609
|
+
Hono `Context` pre-typed with [`CloudEnv`](#cloudenv). This is the type of the `c` parameter in all route handlers and middleware.
|
|
610
|
+
|
|
611
|
+
```ts
|
|
612
|
+
import type { CloudContext } from 'void';
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
### `CloudEnv`
|
|
616
|
+
|
|
617
|
+
Hono environment type for Void workers. Extends Hono's `Env` with Cloudflare bindings and context variables.
|
|
618
|
+
|
|
619
|
+
```ts
|
|
620
|
+
interface CloudEnv extends Env {
|
|
621
|
+
Bindings: {
|
|
622
|
+
DB: D1Database;
|
|
623
|
+
KV: KVNamespace;
|
|
624
|
+
STORAGE: R2Bucket;
|
|
625
|
+
AI: Ai;
|
|
626
|
+
SANDBOX: DurableObjectNamespace<import('@cloudflare/sandbox').Sandbox>;
|
|
627
|
+
[key: string]: unknown;
|
|
628
|
+
};
|
|
629
|
+
Variables: CloudContextVariables;
|
|
630
|
+
}
|
|
631
|
+
```
|
|
632
|
+
|
|
633
|
+
### `CloudContextVariables`
|
|
634
|
+
|
|
635
|
+
The context variables type used by `c.set()` / `c.get()`. Augment this interface to add typed variables that flow through all middleware and handlers:
|
|
636
|
+
|
|
637
|
+
```ts
|
|
638
|
+
interface CloudContextVariables {
|
|
639
|
+
user: AuthUser | null;
|
|
640
|
+
session: AuthSession | null;
|
|
641
|
+
[key: string]: unknown;
|
|
642
|
+
}
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
**Augmentation example:**
|
|
646
|
+
|
|
647
|
+
```ts
|
|
648
|
+
declare module 'void' {
|
|
649
|
+
interface CloudContextVariables {
|
|
650
|
+
requestId: string;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
// c.get("requestId") → string
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
See [Type Safety](../guide/type-safety.md#context-variables) for details.
|
|
658
|
+
|
|
659
|
+
### `TypedHandler<V, R>`
|
|
660
|
+
|
|
661
|
+
The return type of `defineHandler`. Carries phantom types for validators (`V`) and return type (`R`) used by the codegen to produce typed routes.
|
|
662
|
+
|
|
663
|
+
```ts
|
|
664
|
+
interface TypedHandler<V extends ValidatorSlots = {}, R = unknown> {
|
|
665
|
+
(c: CloudContext): Promise<Response> | Response | unknown;
|
|
666
|
+
readonly __validators: V; // type-level only
|
|
667
|
+
readonly __output: R; // type-level only
|
|
668
|
+
}
|
|
669
|
+
```
|
|
670
|
+
|
|
671
|
+
### `HeadDescriptor`
|
|
672
|
+
|
|
673
|
+
Shape of page head metadata returned by `defineHead`. All fields are optional.
|
|
674
|
+
|
|
675
|
+
```ts
|
|
676
|
+
interface HeadDescriptor {
|
|
677
|
+
title?: string;
|
|
678
|
+
meta?: Array<{ name?: string; property?: string; content?: string; charset?: string }>;
|
|
679
|
+
link?: Array<{ rel: string; href: string; [key: string]: string | undefined }>;
|
|
680
|
+
script?: Array<{ src?: string; innerHTML?: string; [key: string]: string | undefined }>;
|
|
681
|
+
htmlAttrs?: Record<string, string>;
|
|
682
|
+
bodyAttrs?: Record<string, string>;
|
|
683
|
+
}
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
### `RouteMap`
|
|
687
|
+
|
|
688
|
+
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.
|
|
689
|
+
|
|
690
|
+
```ts
|
|
691
|
+
import type { RouteMap } from 'void/routes';
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
## Environment Types
|
|
695
|
+
|
|
696
|
+
Importing `"void/env"` provides global Cloudflare environment types:
|
|
697
|
+
|
|
698
|
+
```ts
|
|
699
|
+
/// <reference types="void/env" />
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
Declares the `Cloudflare.Env` namespace with `DB`, `KV`, `STORAGE`, `AI`, and `SANDBOX` binding types.
|
|
703
|
+
|
|
704
|
+
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()`.
|
|
705
|
+
|
|
706
|
+
## Framework Adaptors
|
|
707
|
+
|
|
708
|
+
Framework adaptors for [Pages Routing](../guide/pages-routing/overview). Each adaptor provides a Vite plugin and client-side runtime.
|
|
709
|
+
|
|
710
|
+
### `@void/vue`
|
|
711
|
+
|
|
712
|
+
#### `voidVue(options?)`
|
|
713
|
+
|
|
714
|
+
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.
|
|
715
|
+
|
|
716
|
+
```ts
|
|
717
|
+
import { voidVue } from '@void/vue/plugin';
|
|
718
|
+
|
|
719
|
+
export default defineConfig({
|
|
720
|
+
plugins: [voidPlugin(), voidVue()],
|
|
721
|
+
});
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
**Signature:**
|
|
725
|
+
|
|
726
|
+
```ts
|
|
727
|
+
function voidVue(options?: VoidVueOptions): Plugin[];
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
**Options:**
|
|
731
|
+
|
|
732
|
+
```ts
|
|
733
|
+
interface VoidVueOptions {
|
|
734
|
+
vue?: VuePluginOptions; // passed through to @vitejs/plugin-vue
|
|
735
|
+
}
|
|
736
|
+
```
|
|
737
|
+
|
|
738
|
+
#### Vue Runtime
|
|
739
|
+
|
|
740
|
+
Imported from `"@void/vue"`.
|
|
741
|
+
|
|
742
|
+
| Export | Description |
|
|
743
|
+
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
744
|
+
| `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`. |
|
|
745
|
+
| `useRouter()` | Returns the Void Router with current route state (`url`, `path`, `query`) and navigation methods: `visit`, `refresh`, awaitable `prefetch`, `flush`, `flushAll`. |
|
|
746
|
+
| `useNavigation()` | Returns pending navigation state: `{ state, location, method }`, where `state` is `"idle"`, `"loading"`, or `"submitting"` and `location` is the pending destination. |
|
|
747
|
+
| `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 }`. |
|
|
748
|
+
| `useShared()` | Returns shared data injected by middleware via `c.set("shared", {...})`. |
|
|
749
|
+
|
|
750
|
+
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.
|
|
751
|
+
|
|
752
|
+
### `@void/react`
|
|
753
|
+
|
|
754
|
+
#### `voidReact(options?)`
|
|
755
|
+
|
|
756
|
+
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.
|
|
757
|
+
|
|
758
|
+
```ts
|
|
759
|
+
import { voidReact } from '@void/react/plugin';
|
|
760
|
+
|
|
761
|
+
export default defineConfig({
|
|
762
|
+
plugins: [voidPlugin(), voidReact()],
|
|
763
|
+
});
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
**Signature:**
|
|
767
|
+
|
|
768
|
+
```ts
|
|
769
|
+
function voidReact(options?: VoidReactOptions): Plugin[];
|
|
770
|
+
```
|
|
771
|
+
|
|
772
|
+
**Options:**
|
|
773
|
+
|
|
774
|
+
```ts
|
|
775
|
+
interface VoidReactOptions {
|
|
776
|
+
react?: ReactPluginOptions; // passed through to @vitejs/plugin-react
|
|
777
|
+
viewTransitions?: boolean; // enable View Transitions API for navigations
|
|
778
|
+
prefetch?: {
|
|
779
|
+
hoverDelay?: number;
|
|
780
|
+
cacheFor?: number | string | [string, string];
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
#### React Runtime
|
|
786
|
+
|
|
787
|
+
Imported from `"@void/react"`.
|
|
788
|
+
|
|
789
|
+
| Export | Description |
|
|
790
|
+
| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
791
|
+
| `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`. |
|
|
792
|
+
| `useRouter()` | Returns the Void Router with current route state (`url`, `path`, `query`) and navigation methods: `visit`, `refresh`, awaitable `prefetch`, `flush`, `flushAll`. React navigations are scheduled as transitions. |
|
|
793
|
+
| `useNavigation()` | Returns pending navigation state: `{ state, location, method }`, where `state` is `"idle"`, `"loading"`, or `"submitting"` and `location` is the pending destination. |
|
|
794
|
+
| `useForm(url, defaults, options?)` | Form helper hook. Returns `{ data, setData, post, put, patch, delete, pending, errors, error, hasChanges, wasSuccessful, recentlySuccessful, reset, clearErrors, clearError }`. |
|
|
795
|
+
| `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`. |
|
|
796
|
+
| `useShared()` | Returns shared data injected by middleware via `c.set("shared", {...})`. |
|
|
797
|
+
| `Deferred<T>` | React-only prop type for `defer()` results. It is `Promise<T>` and is consumed with React `use()`. |
|
|
798
|
+
|
|
799
|
+
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.
|
|
800
|
+
|
|
801
|
+
React deferred props returned from `defer()` are Suspense resources. Read them
|
|
802
|
+
with React's `use()` inside a `<Suspense>` boundary. React Pages requires React
|
|
803
|
+
19 and uses streaming SSR for the initial deferred shell. Rejections throw from
|
|
804
|
+
`use()`, so use a normal React error boundary for custom deferred error UI. Vue,
|
|
805
|
+
Svelte, and Solid keep the `{ loading, value, error }` deferred state object.
|
|
806
|
+
When explicitly annotating props, import `Deferred` from the framework adapter
|
|
807
|
+
package (`@void/react`, `@void/vue`, `@void/svelte`, or `@void/solid`) so the
|
|
808
|
+
type matches that adapter's client runtime shape.
|
|
809
|
+
|
|
810
|
+
### `@void/svelte`
|
|
811
|
+
|
|
812
|
+
#### `voidSvelte(options?)`
|
|
813
|
+
|
|
814
|
+
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.
|
|
815
|
+
|
|
816
|
+
```ts
|
|
817
|
+
import { voidSvelte } from '@void/svelte/plugin';
|
|
818
|
+
|
|
819
|
+
export default defineConfig({
|
|
820
|
+
plugins: [voidPlugin(), voidSvelte()],
|
|
821
|
+
});
|
|
822
|
+
```
|
|
823
|
+
|
|
824
|
+
**Signature:**
|
|
825
|
+
|
|
826
|
+
```ts
|
|
827
|
+
function voidSvelte(options?: VoidSvelteOptions): Plugin[];
|
|
828
|
+
```
|
|
829
|
+
|
|
830
|
+
**Options:**
|
|
831
|
+
|
|
832
|
+
```ts
|
|
833
|
+
interface VoidSvelteOptions {
|
|
834
|
+
svelte?: SveltePluginOptions; // passed through to @sveltejs/vite-plugin-svelte
|
|
835
|
+
viewTransitions?: boolean; // enable View Transitions API
|
|
836
|
+
}
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
#### Svelte Runtime
|
|
840
|
+
|
|
841
|
+
Imported from `"@void/svelte"`.
|
|
842
|
+
|
|
843
|
+
| Export | Description |
|
|
844
|
+
| ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
845
|
+
| `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`. |
|
|
846
|
+
| `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 }`. |
|
|
847
|
+
| `useShared()` | Returns shared data injected by middleware via `c.set("shared", {...})`. |
|
|
848
|
+
| `useRouter()` | Returns the Void Router with current route state (`url`, `path`, `query`) and navigation methods: `visit`, `refresh`, awaitable `prefetch`, `flush`, `flushAll`. |
|
|
849
|
+
| `useNavigation()` | Returns pending navigation state: `{ state, location, method }`, where `state` is `"idle"`, `"loading"`, or `"submitting"` and `location` is the pending destination. |
|
|
850
|
+
|
|
851
|
+
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.
|
|
852
|
+
|
|
853
|
+
### `@void/solid`
|
|
854
|
+
|
|
855
|
+
#### `voidSolid(options?)`
|
|
856
|
+
|
|
857
|
+
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.
|
|
858
|
+
|
|
859
|
+
```ts
|
|
860
|
+
import { voidSolid } from '@void/solid/plugin';
|
|
861
|
+
|
|
862
|
+
export default defineConfig({
|
|
863
|
+
plugins: [voidPlugin(), voidSolid()],
|
|
864
|
+
});
|
|
865
|
+
```
|
|
866
|
+
|
|
867
|
+
**Signature:**
|
|
868
|
+
|
|
869
|
+
```ts
|
|
870
|
+
function voidSolid(options?: VoidSolidOptions): Plugin[];
|
|
871
|
+
```
|
|
872
|
+
|
|
873
|
+
**Options:**
|
|
874
|
+
|
|
875
|
+
```ts
|
|
876
|
+
interface VoidSolidOptions {
|
|
877
|
+
solid?: SolidPluginOptions; // passed through to vite-plugin-solid
|
|
878
|
+
viewTransitions?: boolean; // enable View Transitions API
|
|
879
|
+
}
|
|
880
|
+
```
|
|
881
|
+
|
|
882
|
+
#### Solid Runtime
|
|
883
|
+
|
|
884
|
+
Imported from `"@void/solid"`.
|
|
885
|
+
|
|
886
|
+
| Export | Description |
|
|
887
|
+
| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
888
|
+
| `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`. |
|
|
889
|
+
| `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 }`. |
|
|
890
|
+
| `useShared()` | Returns shared data injected by middleware via `c.set("shared", {...})`. |
|
|
891
|
+
| `useRouter()` | Returns the Void Router with current route state (`url`, `path`, `query`) and navigation methods: `visit`, `refresh`, awaitable `prefetch`, `flush`, `flushAll`. |
|
|
892
|
+
| `useNavigation()` | Returns pending navigation state: `{ state, location, method }`, where `state` is `"idle"`, `"loading"`, or `"submitting"` and `location` is the pending destination. |
|
|
893
|
+
|
|
894
|
+
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.
|
|
895
|
+
|
|
896
|
+
## Subpath Exports
|
|
897
|
+
|
|
898
|
+
| Import path | Contents |
|
|
899
|
+
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
900
|
+
| `void` | `voidPlugin` named export + all handler/type re-exports |
|
|
901
|
+
| `void/handler` | `defineHandler`, `defineMiddleware`, `defineScheduled`, `defineQueue`, `defineRender`, `defineHead`, types |
|
|
902
|
+
| `void/auth` | `defineAuth`, `getUser`, `getSession`, `requireAuth`, `AuthUser`, `AuthSession`, `AuthState` |
|
|
903
|
+
| `void/client` | `fetch`, `fetchStream`, `FetchError`, `auth`, `createAuthClient`, `AuthUser`, `AuthSession`, `AuthState` |
|
|
904
|
+
| `void/ws` | `defineRoom`, `defineWebSocket`, `connect`, WebSocket context and connection types |
|
|
905
|
+
| `void/response` | `convertReturnValue` |
|
|
906
|
+
| `void/validator` | `runValidation`, `ValidatorSlots`, `HandlerInput` |
|
|
907
|
+
| `void/drizzle-zod` | Re-exports [`drizzle-zod`](https://orm.drizzle.team/docs/zod) for schema-derived Zod validators for Drizzle tables |
|
|
908
|
+
| `void/drizzle-valibot` | Re-exports [`drizzle-valibot`](https://orm.drizzle.team/docs/typebox) for schema-derived Valibot validators for Drizzle tables |
|
|
909
|
+
| `void/drizzle-arktype` | Re-exports [`drizzle-arktype`](https://orm.drizzle.team/docs/arktype) for schema-derived ArkType validators for Drizzle tables |
|
|
910
|
+
| `void/schema-d1` | Re-exports [`drizzle-orm/sqlite-core`](https://orm.drizzle.team/docs/column-types/sqlite) for D1 table and column builders |
|
|
911
|
+
| `void/schema-pg` | Re-exports [`drizzle-orm/pg-core`](https://orm.drizzle.team/docs/column-types/pg) for PostgreSQL table and column builders |
|
|
912
|
+
| `void/db` | `db` ([Drizzle D1](https://orm.drizzle.team/docs/get-started/d1-new) instance), `createDb`, query operators (`eq`, `and`, `or`, `desc`, `like`, `inArray`, etc.) |
|
|
913
|
+
| `void/seed` | `defineSeed`, `SeedContext`, `SeedFn` for programmatic `void db seed` modules |
|
|
914
|
+
| `void/routes` | `RouteMap` and `WebSocketRouteMap` stubs (types only) |
|
|
915
|
+
| `void/queues` | `queues` proxy for sending messages to typed queues |
|
|
916
|
+
| `void/sandbox` | `getSandbox`, `sandbox`, `Sandbox`, and sandbox option types from the Cloudflare Sandbox SDK. `getSandbox(id)` resolves to the same Durable Object instance for a given `id` across all deploys and rollbacks. DO-level storage (`ctx.storage`) is durable; the container filesystem, processes, and exposed ports are tied to a single container lifetime and are lost on idle (`sleepAfter`, default `10m`), crash, or platform restart. See [Sandboxes › State persistence](../guide/sandboxes.md#state-persistence). |
|
|
917
|
+
| `void/env` | Global Cloudflare env types (types only) |
|