Documentation Index
Fetch the complete documentation index at: https://mintlify.com/eersnington/sideffect/llms.txt
Use this file to discover all available pages before exploring further.
withCloudflareWorkflows is the primary Vite integration function for Sideffect. It wraps Cloudflare’s Vite plugin factory, scans your configured workflow directories for Workflow.make(...).toLayer(...) exports, auto-generates Cloudflare workflow bindings, writes a sideffect-env.d.ts type declaration file, and replaces the Worker entry with a generated virtual module that exports named WorkflowEntrypoint subclasses. Import it from sideffect/vite.
Function signature
plugins array using the ... spread operator.
Parameters
The
cloudflare factory function imported from @cloudflare/vite-plugin. Sideffect calls it
internally after merging workflow bindings into the resolved Worker config, so you must pass the
factory itself rather than its return value.Optional configuration for Sideffect workflow discovery and Cloudflare plugin forwarding.
All fields are optional; sensible defaults apply.
Directories or individual files to scan for Sideffect workflow layers.
Sideffect uses TypeScript’s AST parser to find static
Workflow.make({ name }).toLayer(...)
export declarations and follows local barrel re-exports.Accepts absolute paths or paths relative to the Wrangler config directory (or process.cwd() if
no configPath is set).Default: ["src/workflows"]Override the Worker entry module path when it cannot be resolved from the Wrangler config.
Useful for monorepos or non-standard project layouts where
main is not set.Path to the Wrangler config file (
wrangler.toml or wrangler.json).
Forwarded unchanged to @cloudflare/vite-plugin. Also used as the base directory for resolving
workflowPaths when specified.A partial
WorkerConfig object or a customizer function that is merged with the Wrangler config
before Sideffect injects its generated workflow bindings. Matches Cloudflare’s native config
option behavior.Enables local state persistence in Miniflare during
vite dev.true— uses the default Miniflare persistence directory.{ path: string }— uses the specified directory.
V8 inspector port for Worker debugging. Pass
false to disable the inspector entirely.When
true, Cloudflare uses real remote bindings (KV, R2, D1, etc.) during local development
instead of Miniflare simulations.Additional Workers to run or build alongside the entry Worker. Each entry mirrors Cloudflare’s
auxiliary Worker config shape, accepting either a
configPath or an inline config customizer.Vite environment settings for the entry Worker. Use
name to specify which Vite environment the
Worker runs in (for example "ssr" in a TanStack Start project). Optionally specify
childEnvironments to associate additional Vite environments with this Worker.When
true (or a function returning true), the entry Worker is omitted from production builds
and only used for local development. Forwarded unchanged to @cloudflare/vite-plugin.Cloudflare Tunnel sharing options for
vite dev or vite preview servers.true— starts a quick Cloudflare Tunnel automatically.{ autoStart, name }— optionally auto-start and/or use a named Cloudflare Tunnel instead of a quick tunnel.
Experimental Cloudflare Vite plugin options forwarded unchanged.
Includes
headersAndRedirectsDevModeSupport, prerenderWorker, and newConfig.Return value
A two-element array:
[sideffectPlugin, cloudflarePlugin]. Spread it directly into Vite’s
plugins array.Examples
Minimal setup
The simplest usage — scan the defaultsrc/workflows directory and forward no extra Cloudflare options.
With custom workflow paths and state persistence
Point Sideffect at a shared monorepo workflow file and enable local state persistence.TanStack Start (with viteEnvironment, inline config, and custom workflow paths)
A full example using TanStack Start where Sideffect’s Worker runs in the "ssr" Vite environment
and the Wrangler config is augmented with Durable Object bindings and a pre-existing native
workflow binding.
Native workflow bindings listed under
config.workflows (those with a script_name pointing to
another Worker, or bindings with no matching Sideffect layer) are preserved and merged into the
final Wrangler config unchanged. Only bindings whose class_name matches a discovered Sideffect
layer are wrapped with a generated WorkflowEntrypoint subclass.Generated artifacts
WhenwithCloudflareWorkflows resolves the Vite config it produces two artifacts:
-
sideffect-env.d.ts— written to the Wrangler config directory. Augments the globalEnvandCloudflare.Envinterfaces with typedWorkflow<Payload>bindings for every discovered Sideffect layer. -
virtual:sideffect/entry— an in-memory Vite virtual module that re-exports everything from your original Worker entry and additionally exports a namedWorkflowEntrypointsubclass for each discovered layer. Cloudflare’s plugin is pointed at this virtual entry instead of your originalmain.