Skip to content

Commit

Permalink
Clarify useNavigate vs redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
brenelz committed Sep 27, 2024
1 parent cfbe675 commit 1a86d17
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
title: Response helpers
---

**Note:** These response helpers must be called within a `cache` or `action` function. If you want to
programmatically navigate, you will want to use the [useNavigate](/solid-router/reference/primitives/use-navigate) primitive.

## Redirect

Signature: `redirect(path, options)`
Expand Down
3 changes: 3 additions & 0 deletions src/routes/solid-router/reference/primitives/use-navigate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ if (unauthorized) {
}
```

If you are inside of a `cache` or `action` function you will instead want to use [redirect](/solid-router/reference/data-apis/response-helpers#redirect) or [reload](/solid-router/reference/data-apis/response-helpers#reload).

<Callout>
The state is serialized using the [structured clone
algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm)
which does not support all object types.
</Callout>

0 comments on commit 1a86d17

Please sign in to comment.