glide.messengers API enables bidirectional, type-safe communication between the main browser process and content processes.
glide.messengers.create()
Create a messenger that can communicate with content processes.Parameters
Callback invoked when messages are sent from the content processArguments:
message- Object containingnameanddataproperties based on your message type definitions
Returns
Returns aParentMessenger object with:
Execute a callback in the content process with access to a messengerParameters:
callback- Function that receives aContentMessengeras first argumentopts.tab_id- Tab ID or tab object where the callback will execute
Type Definitions
ParentMessenger
ContentMessenger
Usage Examples
Basic Message Passing
Create a messenger and send messages from content to main process:Tracking User Interactions
Monitor specific user interactions within web pages:Simple Notification System
Error Handling
If an error occurs in the receiver callback, Glide will display a notification with the error message:Communication Flow
- Create messenger in main process with
glide.messengers.create() - Define receiver to handle incoming messages
- Execute in content using
messenger.content.execute() - Send messages from content process using
messenger.send() - Receive in main process via the receiver callback
Type Safety
Messengers provide full TypeScript type safety:- Message names are restricted to keys of your
Messagestype - Message data types are inferred from your definitions
- Invalid message names or data cause compile-time errors
Limitations
- Communication is currently uni-directional: content → main process only
- The
messenger.content.execute()callback cannot accept custom arguments (unlikeglide.content.execute()) - Only one message can be sent per
messenger.send()call
See Also
- glide.content - Execute code in content processes
- glide.excmds - Create custom commands
- glide.keymaps - Define keyboard mappings