π Description of content that is out-of-date or incorrect
You can register service workers in entry-client.tsx
Here's how you create a service worker with raw JavaScript:
Write service worker file and place this in the public folder. eg public/sw.js
In entry-client.tsx, register your service worker:
import { StartClient, mount } from '@solidjs/start/client'
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js', { scope: '/' }).then(
(registration) => {
console.log('Service worker registration succeeded:', registration)
},
(error) => {
console.error(`Service worker registration failed: ${error}`)
},
)
} else {
console.error('Service workers are not supported.')
}
mount(() => <StartClient />, document.getElementById('app')!)
Now the service worker should apply to all paths after /
π₯οΈ Reproduction in StackBlitz (if reporting incorrect content or code samples)
I've used this in my own solid start app.
Since I've used service workers before, this wasn't too hard to figure out.
But I'd imagine this is not intuitive for those who are unfamiliar with service workers.
π Subject area/topic
Service Worker
π Page(s) affected (or suggested, for new content)
/solid-start/reference/entrypoints/entry-client.mdx
π Description of content that is out-of-date or incorrect
You can register service workers in
entry-client.tsx
Here's how you create a service worker with raw JavaScript: Write service worker file and place this in the
public
folder. egpublic/sw.js
Inentry-client.tsx
, register your service worker:Now the service worker should apply to all paths after
/
π₯οΈ Reproduction in StackBlitz (if reporting incorrect content or code samples)
No response