Allow configuring loading.js to block route changes #82070
reissbaker
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
The
loading.js
feature is a nice way to show a loading spinner in between pageloads. But, it doesn't block route changes; the route immediately changes and shows the spinner, and only then does the content stream down.Basically:
<Link>
loading.js
rendersThis breaks (simple) CSS view transitions in between pages. For example, if
loading.js
worked like this:<Link>
loading.js
rendersYou could have some simple CSS in
globals.css
like so:And you'd get sick animated page transitions on every page, and loading spinners while any content loads.
However, since the route changes ahead of time, and the content loads in later, you can't use auto navigation view transitions.
Non-Goals
loading.js
, to make simple auto CSS view transitions work)Background
There is a lot of work underway on view transitions in general in React. However, this is AFAIK unrelated to this feature request;
loading.js
is a NextJS feature, not a React feature, and this change would unblock making simple CSS-based auto view transitions work regardless of React support.Proposal
I'm not deeply familiar with how
loading.js
is implemented, but IMO this would probably ideally be a configurable flag in config options, since mostly-client-side apps probably don't care much about blocking and might prefer the existing behavior.Beta Was this translation helpful? Give feedback.
All reactions