Skip to main content
zerotal

Documentation


Documentation / @zerotal/flow / index / FlowProvider

Class: FlowProvider

Defined in: flow/src/provider/FlowProvider.ts:883

The service provider that wires Flow (reactive SSR over WebSocket) into a Zerotal app.

It registers the Router.flow() route macro and the file-route resolver (so flow page Components become routes), and in web/worker/test envs stands up the runtime: builds and serves the client bundle at /__flow/runtime.js, mounts the WebSocket action handler at /__flow/ws (plus the /__flow/http fallback, /__flow/upload, and the session-relay endpoint), and AOT-compiles registered render() methods. In console/repl envs it boots only far enough to enumerate routes and register the make:flow generator. Add it to your app's provider list; it is a dependency of the admin and monitor panels.

Example

// bootstrap/providers.ts
import { FlowProvider } from "@zerotal/flow";

const providers = [
  // …session/auth providers first…
  FlowProvider,
];
export default providers;

Extends

Constructors

Constructor

new FlowProvider(app): FlowProvider

Defined in: core/src/provider/ServiceProvider.ts:44

Parameters

app

Application

Returns

FlowProvider

Inherited from

ServiceProvider.constructor

Other

provides?

static optional provides?: readonly keyof ContainerBindings[]

Defined in: core/src/provider/ServiceProvider.ts:24

Container tokens this provider registers. Required when using the array form of app.defer([Provider, ...]).

Example

static override provides = ['cache'] as const;

Inherited from

ServiceProvider.provides


dependsOn?

static optional dependsOn?: (app) => ServiceProvider[]

Defined in: core/src/provider/ServiceProvider.ts:35

Other providers this one needs. They are pulled into the application automatically (transitively, de-duplicated) and guaranteed to boot before this provider — so you only have to register the feature you want, not its plumbing. Reference the provider classes directly:

Parameters

app

Application

Returns

ServiceProvider

Example

static override dependsOn = [FlowProvider];

Inherited from

ServiceProvider.dependsOn


priority?

static optional priority?: number

Defined in: core/src/provider/ServiceProvider.ts:42

Boot-order tiebreak among providers with no dependsOn relationship. Lower boots earlier; defaults to 0. Handy for framework-core providers (e.g. static override priority = -100).

Inherited from

ServiceProvider.priority


app

protected app: Application

Defined in: core/src/provider/ServiceProvider.ts:44

Inherited from

ServiceProvider.app


onStarted()

onStarted(): Promise<void>

Defined in: core/src/provider/ServiceProvider.ts:55

Run once the app has started.

Returns

Promise<void>

Inherited from

ServiceProvider.onStarted


onStopped()

onStopped(): Promise<void>

Defined in: core/src/provider/ServiceProvider.ts:59

Run once shutdown is complete.

Returns

Promise<void>

Inherited from

ServiceProvider.onStopped


onRequestReceived()

onRequestReceived(_ctx): Promise<void>

Defined in: core/src/provider/ServiceProvider.ts:66

Called before the middleware pipeline runs.

Parameters

_ctx

HttpContext

Returns

Promise<void>

Inherited from

ServiceProvider.onRequestReceived


onRequestProcessed()

onRequestProcessed(_ctx): Promise<void>

Defined in: core/src/provider/ServiceProvider.ts:69

Called after the pipeline completes and ctx.response is set.

Parameters

_ctx

HttpContext

Returns

Promise<void>

Inherited from

ServiceProvider.onRequestProcessed


onResponseSent()

onResponseSent(_ctx): Promise<void>

Defined in: core/src/provider/ServiceProvider.ts:72

Called after the response has been sent to the client.

Parameters

_ctx

HttpContext

Returns

Promise<void>

Inherited from

ServiceProvider.onResponseSent


replContext()

replContext(): Record<string, unknown>

Defined in: core/src/provider/ServiceProvider.ts:81

Variables to expose in bun zt repl. Override in any provider to make its facades available by name in the REPL session.

Returns

Record<string, unknown>

Example

override replContext() { return { DB, Mail }; }

Inherited from

ServiceProvider.replContext


environments

static environments: AppEnvironment[]

Defined in: flow/src/provider/FlowProvider.ts:891

Environments in which this provider is active. Defaults to all of them.

Overrides

ServiceProvider.environments


onStopping()

onStopping(): Promise<void>

Defined in: flow/src/provider/FlowProvider.ts:895

Run when the app begins a graceful shutdown; release resources here.

Returns

Promise<void>

Overrides

ServiceProvider.onStopping


persistentMiddleware

static persistentMiddleware: (string | MiddlewareClass)[]

Defined in: flow/src/provider/FlowProvider.ts:914

Global middleware re-applied on every WebSocket update (Livewire-style persistent middleware). Matched against the app's global pipeline by class reference or class name. Route middleware always re-runs and does not need to be listed here.


onRegister()

onRegister(): void

Defined in: flow/src/provider/FlowProvider.ts:949

Register container bindings. Runs before any provider boots; do not resolve services here.

Returns

void

Overrides

ServiceProvider.onRegister


onBooting()

onBooting(): Promise<void>

Defined in: flow/src/provider/FlowProvider.ts:965

Resolve and prepare services before the app is considered booted.

Returns

Promise<void>

Overrides

ServiceProvider.onBooting


onStarting()

onStarting(): Promise<void>

Defined in: flow/src/provider/FlowProvider.ts:1174

AOT-compile and validate registered Component render() methods.

Must run in onStarting() — after Application.boot() — so that _loadFileRoutes() has already set __sourceFile on each page class. Running earlier (onBooting/onBooted) causes all pages to be skipped because __sourceFile is undefined at that point.

Returns

Promise<void>

Overrides

ServiceProvider.onStarting


onBooted()

onBooted(): Promise<void>

Defined in: flow/src/provider/FlowProvider.ts:1200

Register dev build hooks so DevOrchestrator rebuilds CSS and JS bundles when files in resources/css/ or resources/js/ change during serve --dev.

Both hooks are no-ops when the corresponding entry point does not exist, so apps without Tailwind or a JS bundle are unaffected.

resources/css/app.css → public/css/app.css (Tailwind v4) resources/js/app.js → public/js/app.js (browser ESM bundle)

Returns

Promise<void>

Overrides

ServiceProvider.onBooted

Provider

persistMiddleware()

static persistMiddleware(...middleware): void

Defined in: flow/src/provider/FlowProvider.ts:929

Add global middleware to the persistent list — middleware re-run on every WebSocket action, matched by class reference or class name.

Parameters

middleware

...(string | MiddlewareClass)[]

Middleware classes or their names to mark persistent.

Returns

void

Example

// In a ServiceProvider's register/boot:
FlowProvider.persistMiddleware(TenantMiddleware, 'LocaleMiddleware');

registerSynth()

static registerSynth(synth): void

Defined in: flow/src/provider/FlowProvider.ts:1272

Register a custom synthesizer (serialization handler for a property type) before the app boots.

Parameters

synth

Synth<unknown>

The synthesizer to register.

Returns

void