molefrog / wouter

🥢 A minimalist-friendly ~2.1KB routing for React and Preact
https://npm.im/wouter
The Unlicense
6.65k stars 152 forks source link

Handle Browser Back and Forward Buttons with Custom Page Transition #470

Open Kusou1 opened 2 months ago

Kusou1 commented 2 months ago

I have a hook to handle link button clicks. When a link button is clicked, a page transition is shown and animated. After the animation completes, the location is set to the target address.

However, I have a question regarding handling the browser's back and forward buttons. When the back button is clicked, I want to:

Prevent the default event that navigates to the previous page. Set the target address. Animate the page transition. After the animation completes, set the location to the target address. Could you please provide an solution for this?

molefrog commented 1 month ago

Could you please share how you're implementing delayed transitions? Are you using Suspense?