@osiris-smarttv/keep-alive
v0.1.1
Published
Route & component keep-alive for React TV apps — AliveScope, KeepAlive, LRU cache, lifecycle events
Maintainers
Readme
@osiris-smarttv/keep-alive
Keep-alive and page-cache toolkit for React TV applications.
@osiris-smarttv/keep-alive helps retain expensive screens/components across route transitions, with explicit lifecycle hooks and cache control policies designed for lean-back TV UX.
Why use it
- Preserve screen state when navigating between tabs/routes
- Avoid remount cost for heavy TV pages
- Control eviction with LRU and manual policies
- Emit lifecycle events for analytics/cleanup
- Integrate with React Router through dedicated adapters
Install
npm i @osiris-smarttv/keep-aliveExports
@osiris-smarttv/keep-alive- React bindings + router helpers + core types@osiris-smarttv/keep-alive/core- pure cache/policy/event primitives@osiris-smarttv/keep-alive/router- React Router-focused entry@osiris-smarttv/keep-alive/styles.css- optional base styles
Quick start (React)
import { AliveScope, KeepAlive } from '@osiris-smarttv/keep-alive'
export function App() {
return (
<AliveScope>
<KeepAlive cacheKey="home-screen">
<HomeScreen />
</KeepAlive>
</AliveScope>
)
}React Router usage
import { KeepAliveOutlet } from '@osiris-smarttv/keep-alive/router'
export function ShellLayout() {
return <KeepAliveOutlet />
}Core API highlights
From @osiris-smarttv/keep-alive/core:
AliveEventBusCacheEvictionModemergeCachePolicyDEFAULT_CACHE_POLICYDEFAULT_PAGE_CACHE_POLICYDEFAULT_STACK_CACHE_POLICY
React hooks
useAliveController()usePageCache()useActivate()useUnactivate()useAliveLifecycle()
Source privacy on npm
This package is published as a public npm package, but npm tarballs include only:
dist/**README.md- metadata files (
package.json,LICENSE)
Source files under src/** are excluded by the files allowlist in package.json.
Local development
yarn install
yarn build
yarn typecheck
yarn testManual publish
yarn publish:check
yarn publish:dry-run
yarn publish:manual