solidjs / solid-docs-next

SolidJS Docs.
https://docs.solidjs.com/
212 stars 244 forks source link

[Request]: When to use useNavigate vs redirect #820

Open klequis opened 1 month ago

klequis commented 1 month ago

What is this request related to?

Request

πŸ“‹ Suggested

And maybe in here as well: https://docs.solidjs.com/solid-router/reference/primitives/use-navigate

πŸ“‹ General description or bullet points

Solid router has useNavigate and redirect. It wasn't clear to my why. I asked in Discord

@klequis

└── πŸ“categories
    └── [...notfound].jsx
    └── keyboards.jsx
    └── mice.jsx

I want [...notfund].jsx to redirect/navigate to /products/index.jsx. Does it matter if I use redirect vs useNavigate?

And got an answer from Ryan I would not have thought of:

"redirect actually only works inside cache and action functions (edited) everywhere else useNavigate"

This seems like a good add to the doc.

πŸ–₯️ Reproduction of code samples in StackBlitz

No response