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
* Implement support for `aroundNav` handler.
* Support view transitions in the magazin example.
* Update router.d.ts
* Transition product image.
* Add View Transitions to docs.
* Try to hack size limit action to use Bun, not npm.
* wouter-preact types are up to date.
Copy file name to clipboardExpand all lines: README.md
+69Lines changed: 69 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,6 +80,7 @@ projects that use wouter: **[Ultra](https://ultrajs.dev/)**,
80
80
-[Can I initiate navigation from outside a component?](#can-i-initiate-navigation-from-outside-a-component)
81
81
-[Can I use _wouter_ in my TypeScript project?](#can-i-use-wouter-in-my-typescript-project)
82
82
-[How can add animated route transitions?](#how-can-add-animated-route-transitions)
83
+
-[How do I add view transitions to my app?](#how-do-i-add-view-transitions-to-my-app)
83
84
-[Preact support?](#preact-support)
84
85
-[Server-side Rendering support (SSR)?](#server-side-rendering-support-ssr)
85
86
-[How do I configure the router to render a specific route in tests?](#how-do-i-configure-the-router-to-render-a-specific-route-in-tests)
@@ -630,6 +631,16 @@ available options:
630
631
631
632
-`hrefs: (href: boolean) => string` — a function for transforming `href` attribute of an `<a />` element rendered by `Link`. It is used to support hash-based routing. By default, `href` attribute is the same as the `href` or `to` prop of a `Link`. A location hook can also define a `hook.hrefs` property, in this case the `href` will be inferred.
632
633
634
+
-**`aroundNav: (navigate, to, options) => void`** — a handler that wraps all navigation calls. Use this to intercept navigation and perform custom logic before and after the navigation occurs. You can modify navigation parameters, add side effects, or prevent navigation entirely. This is particularly useful for implementing [view transitions](#how-do-i-add-view-transitions-to-my-app). By default, it simply calls `navigate(to, options)`.
635
+
636
+
```js
637
+
constaroundNav= (navigate, to, options) => {
638
+
// do something before navigation
639
+
navigate(to, options); // perform navigation
640
+
// do something after navigation
641
+
};
642
+
```
643
+
633
644
## FAQ and Code Recipes
634
645
635
646
### I deploy my app to the subfolder. Can I specify a base path?
More complex examples involve using `useRoutes` hook (similar to how React Router does it), but wouter does not ship it out-of-the-box. Please refer to [this issue](https://github.com/molefrog/wouter/issues/414#issuecomment-1954192679) for the workaround.
839
850
851
+
### How do I use wouter with View Transitions API?
852
+
853
+
Wouter works seamlessly with the [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API), but you'll need to manually activate it. This is because view transitions require synchronous DOM rendering and must be wrapped in `flushSync` from `react-dom`. Following wouter's philosophy of staying lightweight and avoiding unnecessary dependencies, view transitions aren't built-in. However, there's a simple escape hatch to enable them: the `aroundNav` prop.
0 commit comments