preactjs / preact-router

:earth_americas: URL router for Preact.

Home Page:http://npm.im/preact-router

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Guidance on lazy route loading?

devmattrick opened this issue · comments

I wanted to follow up on some of the discussion on lazy route loading. Right now, the preact-async-route package is deprecated, saying to use Suspense and lazy. However, some of the discussion on the pull request here discourages the use of Suspense and lazy for this purpose.

Is there a recommended pattern for achieving lazy route loading?

I've had this same question for quite a while too.
As far as I can tell this is where things stand regarding lazy routes:

  • The preact team is actively working on Suspense, but it seems unlikely to me that preact-router will be refactored to support it. Their focus is on wmr at the moment, so unless the community refactors preact-cli and preact-router they both face an uncertain future.
  • A preact router that does support lazy loading via Suspense is preact-iso, which ships with wmr. This looks like it could work as a drop-in replacement for preact-router. However the documentation is quite sparse so it is hard to tell.

My plan is to move to react-router until the preact ecosystem has stabilized around a consistent stack.