OpenIM Electron SDK overview
Use WASM documentation as the shared API baseline and understand how Electron WASM and FFI integrations differ.
The Electron SDK supports both WASM and FFI integration. Shared user, conversation, group, message, call, and event capabilities are documented in the WASM SDK documentation. This page explains how to choose an integration and covers the additional FFI APIs and login-parameter differences compared with WASM.
Choose an SDK integration
| Integration | Suitable scenarios | Documentation |
|---|---|---|
| WASM | Browser pages, Electron renderer processes, WebViews, and UIs shared with a Web client | Follow the WASM SDK integration and business guides directly. |
| FFI | Packaged desktop applications, native runtimes, and applications that need absolute local file paths or a separate initSDK lifecycle | Use the Electron-specific pages in this hub together with the shared WASM business pages. |
| WASM + FFI | Products that support both Web and packaged Electron distributions | Wrap a common application-layer interface and select the implementation at runtime. Do not sign the same user in through two SDK instances. |
Integration differences for FFI
The browser WASM package passes server addresses, platform information, and user credentials together in login(InitAndLoginConfig). Electron FFI separates them into two calls:
initSDK(InitConfig)configuresapiAddr,wsAddr,platformID,dataDir,systemType, and logging options.login({ userID, token })submits only the current user's credentials.
See Authenticate and initialize for complete parameters, examples, and unInitSDK(). Continue to follow WASM authentication and session management for shared connection, token, and forced-sign-out event handling.
Electron-specific FFI APIs
| Capability | API | Documentation |
|---|---|---|
| Authentication and lifecycle | initSDK / login / unInitSDK | Authenticate and initialize |
| Media from absolute local paths | createImageMessageFromFullPath and related methods | Create media messages from full paths |
| Upload diagnostic logs | uploadLogs | Upload logs |
Do not call these FFI-only methods from a browser or an Electron application using the WASM package. Continue to use the *ByFile and *ByURL workflows documented for WASM when creating media messages.
Shared capabilities documented under WASM
| Domain | WASM entry point |
|---|---|
| Getting started | Integrate by runtime environment and Send your first message |
| Users | User overview |
| Conversations | Conversation overview |
| Groups | Group overview |
| Messages | Message overview |
| Audio and video calls | Calling overview |
| Events | Event overview |
| Logging levels | Logging. Use the Electron-specific page to upload logs. |
Desktop considerations
- When supporting both Web and Electron, define an application-level IM adapter first and choose WASM or FFI for the current runtime.
- For a WASM integration, verify that
openIM.wasm,sql-wasm.wasm, andwasm_exec.jsremain accessible after packaging. - For an FFI integration, account for desktop packaging, permissions,
dataDir, and upgrade strategy instead of applying browser WASM resource paths. - If both the main and renderer processes need IM state, define the IPC boundary and session ownership before implementation to avoid competing instances.
- Never write user tokens to a preload script or main-process logs.
Was this page helpful?