Skip to main content
A service is a class that extends Service.create() from @zenbujs/core/runtime. It runs in the main process.
src/main/services/files.ts
Every public method is automatically exposed to the renderer process via RPC. You call them through rpc.<plugin>.<service>.<method>, so if this service belongs to a plugin named app, readFile is available as rpc.app.files.readFile(...).

Calling from React

The call is fully type-safe. Parameters and return types are inferred from the service class.

Dependencies

Services declare dependencies on other services through the deps field. The framework automatically figures out the right order to start them in, so each service’s dependencies are ready before it runs.
openWindow({}) boots a main window pointed at your uiEntrypoint. Pass injection: "<name>" to open a window whose entry route renders a specific injection instead. By the time evaluate() runs, all dependencies in this.ctx are fully initialized.

Setups and cleanups

Inside evaluate(), anything that needs to be torn down on hot reload or shutdown should be wrapped in this.setup():
The returned function is the cleanup. It runs before the next setup with the same name, or when the service is torn down.

Hot reloading

When you edit a service file and save, the framework re-evaluates affected services automatically. This works in both development and production.