Use import routes when a handler should be loaded on demand. They are not only a loading choice; they also give build and deployment tooling explicit visibility into route module boundaries.
Example
app.import.get('/users', () => import('./routes/users.js'));// ./routes/users.js
export default function UsersIndex({ res }) {
res.setResults([
{ id: 1, name: 'Ada' },
{ id: 2, name: 'Grace' }
]);
}console.log(app.imports);
// [
// ['GET /users', [{ priority: 0 }]]
// ]Why use this
- reduce initial load
- expose route import metadata to tooling
- keep route registration central while loading handlers lazily