Browse SDKs · Electron
SDKsElectron

OpenIM Electron SDK overview

Use WASM documentation as the shared API baseline and understand how Electron WASM and FFI integrations differ.

Copy

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

IntegrationSuitable scenariosDocumentation
WASMBrowser pages, Electron renderer processes, WebViews, and UIs shared with a Web clientFollow the WASM SDK integration and business guides directly.
FFIPackaged desktop applications, native runtimes, and applications that need absolute local file paths or a separate initSDK lifecycleUse the Electron-specific pages in this hub together with the shared WASM business pages.
WASM + FFIProducts that support both Web and packaged Electron distributionsWrap 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:

  1. initSDK(InitConfig) configures apiAddr, wsAddr, platformID, dataDir, systemType, and logging options.
  2. 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

CapabilityAPIDocumentation
Authentication and lifecycleinitSDK / login / unInitSDKAuthenticate and initialize
Media from absolute local pathscreateImageMessageFromFullPath and related methodsCreate media messages from full paths
Upload diagnostic logsuploadLogsUpload 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

DomainWASM entry point
Getting startedIntegrate by runtime environment and Send your first message
UsersUser overview
ConversationsConversation overview
GroupsGroup overview
MessagesMessage overview
Audio and video callsCalling overview
EventsEvent overview
Logging levelsLogging. 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, and wasm_exec.js remain 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.