Skip to content

Commit

Permalink
Add FAQ entry: navigate outside component
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorchW committed Nov 30, 2023
1 parent 58f20e4 commit 6b08df7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ projects that use wouter: **[Ultra](https://ultrajs.dev/)**,
- [FAQ and How-to's](#faq-and-code-recipes)
- [Base path](#i-deploy-my-app-to-the-subfolder-can-i-specify-a-base-path)
- [Default route](#how-do-i-make-a-default-route)
- [Strict routes](#are-strict-routes-supported)
- [Active links](#how-do-i-make-a-link-active-for-the-current-route)
- [Nested routes](#are-relative-routes-and-links-supported)
- [Multipath routes](#is-it-possible-to-match-an-array-of-paths)
- [Navigating outside components](#can-i-initiate-navigation-from-outside-a-component)
- [TypeScript support](#can-i-use-wouter-in-my-typescript-project)
- [Using with Preact](#preact-support)
- [Server-side Rendering (SSR)](#server-side-rendering-support-ssr)
Expand Down Expand Up @@ -701,6 +702,18 @@ const App = () => (

**[▶ Demo Sandbox](https://codesandbox.io/s/wouter-demo-multipath-routes-42bi3)**

### Can I initiate navigation from outside a component?

Yes, the `navigate` function is exposed from the `"wouter/use-location"` module:

```js
import { navigate } from "wouter/use-location"

navigate("/", { replace: true });
```

It's the same function that is used internally.

### Can I use _wouter_ in my TypeScript project?

Yes! Although the project isn't written in TypeScript, the type definition files are bundled with
Expand Down

0 comments on commit 6b08df7

Please sign in to comment.