You can define client-side configs (import { config } from 'telefunc/client') anywhere, just make sure to do it at global client-side code that is always executed. For example /pages/+client.js if you use Vike:
// /pages/+client.js// Environment: clientimport { config } from 'telefunc/client'// Config values can be set hereconfig.someClientSideSetting = 'some-value'
// /pages/+client.ts// Environment: clientimport { config } from 'telefunc/client'// Config values can be set hereconfig.someClientSideSetting = 'some-value'
Stream transport
Controls how streaming values are delivered over HTTP.
Transport
Content-Type
Description
'binary-inline' (default)
application/octet-stream
Raw binary chunked response. Lowest overhead.
'sse-inline'
text/event-stream
Base64url-encoded SSE. Works through proxies that buffer binary responses.
'channel'
text/plain + channel
Starts over HTTP, then continues over the configured channel transport.
HTTP requests + SSE stream. No extra server setup: works with both new Telefunc() and serve().
'ws'
Multiplexed WebSocket. Extra server setup: works only with new Telefunc() (it supports WebSocket whereas serve() doesn't).
The client default is ['sse', 'ws'] — start on SSE, then upgrade to WebSocket if possible. SSE is supported out-of-the-box, while WebSocket is supported if you set up your server via new Telefunc() (instead of serve()).
The client starts on SSE and upgrades to WebSocket in the background.
All channels share a single multiplexed connection per server URL, so opening many channels doesn't open many connections.
Comparison
Throughput
Recovery
Proxy/CDN
Server setup
'sse'
🟡
✅
✅
None
'ws'
✅
✅
🟡
WebSocket
✅ good · 🟡 partial / caveats
When to use what
Start with 'sse' — it works everywhere out-of-the-box.
Use 'ws' for high-frequency, real-time traffic that benefits from a full-duplex connection.
Recommended setup
Goal
Config
Best default
config.stream.transport = 'binary-inline'
Proxy buffers binary
config.stream.transport = 'sse-inline'
Reconnection
config.stream.transport = 'channel'
Channels without WS
config.channel.transports = ['sse']
Full-duplex channels
config.channel.transports = ['sse', 'ws']
Per-call overrides
Override transport for a single call (instead of globally) with withContext():
// Environment: clientimport { onAIChat } from './Chat.telefunc'import { withContext } from 'telefunc/client'const call = withContext(onAIChat, { stream: { transport: 'channel' }, // override config.stream.transport channel: { transports: ['ws'] }, // override config.channel.transports})const gen = call('Tell me a joke')for await (const message of gen) { console.log(message)}