Skip to content

Services

Services are resource-backed state with an app lifetime. Start with Services and app lifetime for the concept guide.

App authors usually use service helpers from their framework adapter. The direct @starbeam/service package is for adapter and manual integration code.

FrameworkAPINotes
ReactStarbeam provider plus useService(blueprint)The provider establishes the app lifetime.
Preactinstall(options) plus useService(blueprint)The installed adapter owns the app lifetime.
EmbersetupService(blueprint, owner?) or useService(context, blueprint)Services are scoped to the Ember owner.
VueStarbeam plugin plus setupService(blueprint)Install the plugin on the Vue app.
SvelteNot exposed yetThe Svelte adapter does not expose service helpers today.
Terminal window
pnpm add @starbeam/service
import { getServiceFormula, service, Service } from "@starbeam/service";
APIUse for
service(resource, options?)Resolve the singleton value for a resource blueprint in an app.
getServiceFormula(app)Get the formula adapters use to synchronize services for an app.
Service(resource, options?)Wrap a resource blueprint so it resolves through the selected app.
  • A service is a singleton per app object and resource blueprint.
  • Service setup is tied to the app lifetime, not the first component that asks for it.
  • Finalizing the app finalizes services created for that app.
  • Framework adapters own scheduling and app integration.