You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 20, 2026. It is now read-only.
Copy file name to clipboardExpand all lines: docs/primitives/KeepAlive.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,27 @@ const AppRoutes = () => {
32
32
33
33
In the example above, the `Browse` component's state will be preserved. When you navigate away and then back to a `/browse/...` URL, the page will render instantly from the cache, showing exactly what was there before.
34
34
35
+
### Suspending Effects for Cached Routes
36
+
37
+
When a route is cached and hidden (unmounted from view but kept in memory), its reactive SolidJS context remains active. This means any `createEffect` blocks that depend on global signals or stores will continue to run in the background.
38
+
39
+
To prevent background effects from running when the page is inactive, `KeepAliveRoute` injects an `isAlive` accessor into your component's props. You should use `isAlive()` to halt effects early.
40
+
41
+
```jsx
42
+
import { createEffect } from'solid-js';
43
+
44
+
constBrowse= (props) => {
45
+
createEffect(() => {
46
+
// Return early to prevent the effect from running in the background when cached
0 commit comments