@effect/platform-browser package provides browser-specific implementations of Effect’s platform abstractions, enabling you to build client-side applications with HTTP clients, WebSockets, Web Workers, and browser APIs.
Installation
When to Use
Use@effect/platform-browser when:
- Building client-side web applications
- You need to make HTTP requests from the browser
- You want to work with WebSockets or Web Workers
- You need access to browser APIs (geolocation, clipboard, permissions, etc.)
- Building Progressive Web Apps (PWAs)
Core Features
Runtime
TheBrowserRuntime module provides the entry point for running Effect programs in the browser:
- Handles page unload events (cleanup on navigation)
- Automatic error handling
- Integrates with browser lifecycle
HTTP Client
Make HTTP requests using theBrowserHttpClient module (built on fetch API):
- Uses native fetch API
- Automatic CORS handling
- Supports all HTTP methods
- Handles request/response transformations
WebSockets
Connect to WebSocket servers using theBrowserSocket module:
Web Workers
Manage Web Workers with theBrowserWorker module:
Key-Value Storage
Use browser storage (localStorage/sessionStorage) with theBrowserKeyValueStore module:
Browser APIs
Geolocation
Access device location with theGeolocation module:
Clipboard
Interact with the clipboard using theClipboard module:
Permissions
Check and request browser permissions with thePermissions module:
Available Modules
| Module | Description |
|---|---|
BrowserRuntime | Run Effect programs in the browser |
BrowserHttpClient | Make HTTP requests (fetch-based) |
BrowserSocket | WebSocket client |
BrowserWorker | Web Worker management |
BrowserWorkerRunner | Worker runner for parallel processing |
BrowserKeyValueStore | localStorage/sessionStorage access |
BrowserStream | Browser stream integration |
Geolocation | Access device location |
Clipboard | Read/write clipboard |
Permissions | Check and request permissions |
Streams and Reactive Programming
The browser package integrates well with Effect’s Stream module:Integration with UI Frameworks
You can integrate Effect with React, Vue, or other frameworks:Error Handling
Handle browser-specific errors gracefully:Dependencies
The package has minimal external dependencies:- multipasta: Multipart form data handling
Related Packages
- @effect/platform - Core platform abstractions
- @effect/platform-node - Node.js runtime implementations
- @effect/platform-bun - Bun runtime implementations
