Skip to content

Add service workers guide #1043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1a6bcce
Add service workers guide
amirhhashemi Jan 29, 2025
d87c82c
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Jan 29, 2025
f0ce493
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Jan 29, 2025
14df703
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Jan 30, 2025
320a06e
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Jan 30, 2025
12d2f80
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Feb 6, 2025
6b2d5dc
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Feb 6, 2025
fbe48f6
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Feb 7, 2025
bc9ade7
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Feb 7, 2025
8febadc
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Feb 7, 2025
348df50
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Feb 7, 2025
c63883b
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Feb 10, 2025
352446e
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Feb 13, 2025
1e7c032
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Feb 13, 2025
97cff9d
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Feb 13, 2025
9224c27
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Feb 13, 2025
7b5b9ef
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Feb 16, 2025
5dfb8f1
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Feb 16, 2025
2e5fce6
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Feb 16, 2025
5340dd3
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Feb 18, 2025
c98103e
Merge branch 'main' into add-service-worker-guide
kodiakhq[bot] Feb 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/routes/solid-start/guides/data.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"title": "Guides",
"pages": ["data-fetching.mdx", "data-mutation.mdx"]
"pages": ["data-fetching.mdx", "data-mutation.mdx", "service-workers.mdx"]
}
21 changes: 21 additions & 0 deletions src/routes/solid-start/guides/service-workers.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: "Service workers"
---

To register a service worker:

1. Place your service-worker file in the `public` directory (e.g., `public/sw.js`), making it available at the root URL (`/sw.js`).
2. Add registration logic to the `client.entry.tsx` file.

```tsx {6-11} title="src/client.entry.tsx"
// @refresh reload
import { mount, StartClient } from "@solidjs/start/client";

mount(() => <StartClient />, document.getElementById("app")!);

if ("serviceWorker" in navigator && import.meta.env.PROD) {
window.addEventListener("load", () => {
navigator.serviceWorker.register("/sw.js");
});
}
```
Loading