Skip to main content

Parameter decorators

You can inject Electron-specific context directly into your controller methods without parsing the raw event object manually.

DecoratorInjectsType
@Channel()The IPC channel name for this handler (e.g. "users.get_profile")string
@CorrelationId()The unique ID for the current request context. If you have correlation disabled, this will always return undefinedstring
@Origin()The sender frameWebFrameMain
@ProcessId()The ID of the renderer processnumber
@RawEvent()The native Electron event objectIpcMainEvent | IpcMainInvokeEvent
@Sender()The WebContents that sent the messageWebContents
@Window()Nullable. The BrowserWindow that sent the messageBrowserWindow

Example:

import type { WebContents } from "electron/main";

@IpcHandle()
getUserProfile(
@Sender() sender: WebContents,
userId: string
) {
console.log(`Request from window: ${sender.id}`);
return this.userService.findById(userId);
}
note

When using the generated types in the frontend, these injected parameters are automatically removed from the function signature. You simply call getUserProfile('123').