fridays / next-routes

Universal dynamic routes for Next.js
MIT License
2.47k stars 230 forks source link

Imperative API of prefetch doesn't work #126

Closed mocheng closed 6 years ago

mocheng commented 6 years ago

When prefetch with imperative API like this

  routes.getRouter().prefetch('/foo')}

It is expected to prefetch javascript URL in given foo page. However, it just directly prefetch-es /foo. I suppose it should be able to detects which javascript URL without parsing /foo page HTML.

fridays commented 6 years ago

Use routes.Router to get the Router instance.

getRouter is used only internally to wrap the original Router

rizkiandrianto commented 6 years ago

@fridays Still not working even with prefetchRoute() too 🤔

TheBnl commented 5 years ago

I've tried to get the prefetchRoute() method to work as well as following.

// pattern with params
const Component = await Router.prefetchRoute('/:slug', { slug: 'slug' });

// name with params
const Component = await Router.prefetchRoute('name', { slug: 'slug' });

// final route
const Component = await Router.prefetchRoute('/slug');

But all without success. Any help or documentation would be much appreciated!