SolidStart PWA Support
Posting this here since this should be search indexable, right? Becasue there's almost nothing useful relating to this topic >~<...
The main issue is that the manifest and service worker aren’t auto injected since SolidStart's way of bundling is different.
Getting your web app recognized as a PWA
- Install
- Also install
- Add
- Add
- And that should do it, although, note that this doesn’t give offline functionality (that will take a few more tweaks). You may still get terminal warnings but it works well enough for now.
The main issue is that the manifest and service worker aren’t auto injected since SolidStart's way of bundling is different.
Getting your web app recognized as a PWA
- Install
vite-plugin-pwa as a dev dependency and follow this guide.- Also install
@solidjs/meta since it's the recommended way of adding <link>s.- Add
import "vite-plugin-pwa/info"; import "vite-plugin-pwa/solid"; to src/global.d.ts (so typescript will be able to detect some Vite virtual modules we’ll import later).- Add
import { useRegisterSW } from "virtual:pwa-register/solid"; import { pwaInfo } from "virtual:pwa-info"; import { MetaProvider, Link } from "@solidjs/meta"; to your App.tsx file, and edit the main component like this:- And that should do it, although, note that this doesn’t give offline functionality (that will take a few more tweaks). You may still get terminal warnings but it works well enough for now.
