1. Journal Stack Home

useSWEffect

useSWEffect is a React hook that sends updates to the Worker thread whenever relevant changes are made to the main thread (browser).

By default, the worker thread knows nothing about what's going on in the main thread, wether navigation or routing. This hook bridges that by providing regular updates based on location changes (useLocation hook).

root.tsx
import { useSWEffect } from '@remix-pwa/sw'

export default function App() {
  useSWEffect();
  return (
    <div>
      <h1>Hello World</h1>
    </div>
  )
}