About blink-realtime
blink-realtime is a skill for publishing and subscribing to Blink realtime channels through the CLI and SDK. It helps developers build chat, collaboration, notification, gaming, and live dashboard features, with message and presence support.
Key features
- 01Publish events to channels
- 02Subscribe to channel messages
- 03Track channel presence
- 04Use CLI and SDK APIs
Use cases
- 01Build chat with messages and presence
- 02Send alerts to connected clients
- 03Sync collaborative edits or game state
MCP support
It provides the `blink_realtime_publish` tool for publishing an event to a channel through MCP.
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ blink-new/ blink-plugin --skill blink-realtimeAfter installing, type/blink-realtimein Claude Code to confirm it loaded.
Details
From the project READMERequires auth: initialize with auth: { mode: 'managed' } for realtime to work.
Getting Started
# Publish a message to a channel
blink realtime publish chat-room --type message --data '{"text":"Hello everyone!"}'
# Publish with user context
blink realtime publish notifications --type alert --data '{"level":"info","text":"Deploy complete"}'
MCP Tools
| Tool | Description |
|---|---|
blink_realtime_publish | Publish event to a channel |
SDK Methods
// Simple subscribe/publish
const unsubscribe = await blink.realtime.subscribe('chat-room', (message) => {
console.log(message.data)
})
await blink.realtime.publish('chat-room', 'message', { text: 'Hello!' })
unsubscribe()
Channel API (Advanced)
const channel = blink.realtime.channel('game-lobby')
await channel.subscribe({
userId: user.id,
metadata: { displayName: user.name, status: 'online' }
})
channel.onMessage((msg) => {
if (msg.type === 'chat') addMessage(msg.data)
})
channel.onPresence((users) => {
setOnlineUsers(users)
})
await channel.publish('chat', { text: 'Hello!' }, { userId: user.id })
const history = await channel.getMessages({ limit: 50 })
const users = await channel.getPresence()
await channel.unsubscribe()
Message Format
{
id: '1640995200000-0',
type: 'chat',
data: { text: 'Hello!' },
timestamp: 1640995200000,
userId: 'user123',
metadata: { displayName: 'John' }
}
Presence Format
{
userId: 'user123',
metadata: { displayName: 'John', status: 'online' },
joinedAt: 1640995200000,
lastSeen: 1640995230000
}
React Cleanup (Critical)
useEffect(() => {
if (!user?.id) return
let channel: any = null
const init = async () => {
channel = blink.realtime.channel('room')
await channel.subscribe({ userId: user.id })
channel.onMessage((msg: any) => setMessages(prev => [...prev, msg]))
}
init().catch(console.error)
return () => { channel?.unsubscribe() }
}, [user?.id])
Never return cleanup from inside an async function — it gets lost. Store channel reference outside and clean up synchronously.
Use Cases
- Chat apps — messages + presence + history
- Live collaboration — cursor positions, document edits
- Notifications — real-time alerts pushed to connected clients
- Gaming — game state sync, lobby management
- Dashboards — live data updates
Comments
Markdown supported