vike icon indicating copy to clipboard operation
vike copied to clipboard

Navigation interception (for modal routes, `useBlocker()`, ...)

Open brillout opened this issue 8 months ago • 3 comments

Description

The best would be a low-level API for enabling all kinds of features around link interception, such as:

Vike already implements a rough PoC for this, but it isn't released yet. It needs some more love to make it an official feature.

If you want this, write a comment below elaborating your use case. The more I know about possible use cases the better I can design the API.

See also:

brillout avatar Apr 05 '25 21:04 brillout

Modal routes would be great @brillout something like masked routes in tanstack router/start. Its a great use case when you have to show something on a modal keeping the existing content still or mounted behind the modal

for eg my use case is to show a Player modal when i click on a mini player the modal actually gets mounted on a rout, this makes mobile view so intuitive as when you do a back it naturally closes the modal.

live Example: https://sunoh.online (this uses tanstack start)

here is the doc for the masking route from tanstack router: https://tanstack.com/router/v1/docs/framework/react/guide/route-masking

afkcodes avatar Apr 10 '25 06:04 afkcodes

I feel like there is potential for a low-level API that enables all this and more.

In principle, if the user can modify:

  1. The behavior upon navigation (link click or back/forward navigation)
  2. The shown URL

Then all these use cases around "navigation interception" can be implemented. (While vike-{react,vue,solid} can provide high-level helpers for common use cases, like other frameworks.)

@afkcodes Looking at your demo, it seems to be normal modal routing a la Next.js? It doens't seem to use TanStack's route masking feature?

The more use cases I know about, the better.

brillout avatar Apr 11 '25 07:04 brillout

Its actually built using tanstack-start @brillout , yeah its kind of similar to modal route, but its using masking route from tanstack start/router

afkcodes avatar Apr 11 '25 17:04 afkcodes