Best Practices
Production guidance for Browser Lifecycle adoption.
Topics
| Topic | Summary |
|---|---|
| Session Lifecycle | One session per tab, explicit start/stop/dispose |
| Memory Management | Unsubscribe and dispose promptly |
| Event Cleanup | Track unsubscribe handles |
| Performance | Disable unused modules |
| Configuration | Validate before start |
| Cross-Tab Communication | Use leadership instead of ad-hoc localStorage |
| Idle Detection | Choose thresholds deliberately |
| Visibility Handling | Pause expensive work when hidden |
| Framework Integration | Keep browser access behind providers |
| Plugin Development | Small hooks, fail safely |
| SSR Safety | Client-only initialization |
| Security | Treat cross-tab messages as untrusted |
| Accessibility | Do not rely on visibility alone for a11y state |
| Testing | Mock capabilities, assert event order |
| Debugging | Use playground and diagnostics APIs |
Recommended
- Initialize Browser Lifecycle once per tab
- Dispose on route or component teardown
- Disable modules you do not use
- Validate configuration before creating a session
- Use typed events instead of raw DOM listeners in application code
Not recommended
- Multiple competing lifecycle instances in one tab
- Passing resolved configuration back into merge helpers
- Subscribing to browser APIs directly when a module already normalizes the signal
- Ignoring plugin errors in production
Playground
Validate recommendations interactively at http://127.0.0.1:4273.
