I am used to working with React Router which offers great flexibility for rendering multiple components from a single route at different places on a page without reloading the entire page. I've included an example below. I would like to use Next.js in future projects but I cant find a way to reproduce this app-like router functionality as Next.js only appears to offer page based routing with no control over the re-render of individual components on a page in response to a route change. This seems to make it good for web pages but not for complex apps that may require multiple changes in response to a single route change.
In the following example I am using React Router in a CRA to render multiple components concurrently on the page based my link configuration. According to my current understanding this appears impossible to reproduce using Next.js.
https://codesandbox.io/s/react-router-component-routes-rcen4
code here:
const BasicExample = () => (
<Router>
<div>
<ul>
<li>
<Link to="/">Home</Link>
</li>
<li>
<Link to="/about">About</Link>
</li>
<li>
<Link to="/about/me">About Me</Link>
</li>
<li>
<Link to="/about/you">About You</Link>
</li>
<li>
<Link to="/topics">Topics</Link>
</li>
</ul>
<hr />
<Route exact path="/" component={Home} />
<Route path="/topics" component={Topics} />
<Route path="/about" component={About} />
<Route path="/about/me" component={AboutMe} />
<Route path="/about/you" component={AboutYou} />
</div>
</Router>
);
Is there a way to efficiently achieve this and render only the components I need in response to a route using Next.js?