Routing
87 bites tagged Routing — interview questions with model answers, and 60-second explainers.
Purpose of Outlet in React Router v6 nested routes
Outlet renders the matched child route inside a parent layout, enabling shared chrome with swappable content; configure nested routes and place Outlet where children render. Nested routing layout knowledge.
Passing params between Stack Navigator screens
Navigate to the route with a params object, read it via route.params on the target, pass an id not a huge object. navigation params basics. using global state or refs to smuggle data instead of route params, or passing.
navigate vs push in a Stack Navigator
Navigate goes to an existing instance of the route if present, otherwise pushes; push always adds a new instance onto the stack. Use push to revisit the same screen with new params. stack navigation semantics.
Modularize routes with express.Router
Create a Router per resource in its own file, define routes on it, export it, and mount with app.use('/products', router). structuring a growing app.
req.params vs req.query vs req.body in Express
Req.params holds named route segments, req.query holds the URL query string, req.body holds the parsed payload. where request data lives. confusing query with params, or expecting req.body without a body parser.
Design an Express route to create a user
POST to a collection URL like /users, read the payload from req.body via express.json(), return 201 with the created resource. REST conventions for creation. using GET to create or putting data in the URL.
Modularizing routes with express.Router
Create a Router instance in users.js, attach routes to it, export it, then mount it under a base path with app.use in the main file. structuring a growing app. duplicating the base path on every route instead of mounting.
Express route order and matching
Express checks routes in definition order, /items/new matches the literal route first, if /:id came first new would be captured as an id. top-down route matching. thinking Express picks the most specific route automatically.
Query params vs route params in Express
Query string values via req.query.q, named path segments via req.params.id, query is optional, route params are part of the matched pattern. distinguishing two ways to pass data in a URL. mixing up req.query and req.params.
Minimal Express Hello World server
Import express, create an app, define app.get on the root sending a response, call app.listen on a port. basic Express setup fluency. forgetting app.listen or confusing the require with the app instance.
Mixture of Experts architecture and routing
Many expert FFNs per layer, a router picks top-k experts per token, only those compute so active params are far fewer than total. grasp of sparse activation and the gating router.
Auth-protected routes via GoRouter redirect
A top-level redirect reads auth state, sends unauthenticated users to login, sends logged-in users away from login, and uses refreshListenable to re-evaluate on auth change. guarding routes with redirect.
Per-tab navigation stacks with StatefulShellRoute
StatefulShellRoute keeps a separate Navigator and preserved state per branch, with a shared shell scaffold. building independent per-tab stacks. rebuilding tab contents or losing scroll and stack on tab switch.
Ingress resource vs Ingress controller
The Ingress resource is declarative routing rules; the controller is the running proxy (NGINX, etc.) that reads them and serves traffic. Separating config from the engine.
Ingress for host and path routing
Use an Ingress with an Ingress controller for layer-7 host/path routing behind one external IP, instead of one cloud LoadBalancer per service. Knowing when to use Ingress.
How do you create a POST API endpoint in SvelteKit?
Add a +server.js file in a src/routes subdirectory, export a POST handler returning a Response, and note that +server files never run in the browser. Filesystem routing and server-only API routes in SvelteKit.
What is the purpose of +page.server.js in SvelteKit?
Exclusively server-side load feeding the data prop, used for secrets like DB queries and private env vars. Server-only load boundaries in SvelteKit. Claiming it runs in the browser or equating it with +page.js.
How do you lazy-load a route in Vue or Angular?
Tests route-level code splitting. Strong answers mention dynamic imports in Vue Router or Angular loadChildren and highlight a smaller initial JS bundle. Red flag: confusing this with image lazy loading or claiming it speeds up runtime navigation.
Contrast SvelteKit file-system routing with Vue/Angular router configs
Contrast SvelteKit directory routes with Vue/Angular config routers; filesystem routing removes boilerplate but couples URLs to folders and limits dynamic registration. Convention-over-configuration tradeoffs.
What is the purpose of an Angular Resolve guard vs ngOnInit?
Tests routing lifecycle timing and UX state management. Strong answers: Resolve blocks activation until data returns; ngOnInit renders first then fetches, causing flicker.
What are nested routes and why are they useful?
Nested routes render children inside a parent's router-view, preserving shared layouts while URL segments swap nested content. hierarchical UI-to-URL mapping. flat routes with duplicated parent wrappers in every child.
How do you configure a route for lazy loading?
Tests route-level code splitting and initial bundle control. Outline: dynamic imports in route config, on-demand chunk fetching, and measurable load-time wins versus eager loading. Red flag: treating lazy loading as just images or components, not route code.
Explain navigation guards and provide an auth use case
Guards are global, per-route, or in-component hooks; returning false cancels, a route object redirects; use auth on /dashboard. Grasp of routing lifecycle interception. Calling them listeners without mentioning returns.
How do you create a dynamic route and access the id parameter?
This tests Vue Router dynamic segment syntax and param access. Define the path with a colon like /products/:id, then read via useRoute().params.id or $route.params.id. A red flag is expecting a remount on param changes or parsing window.location manually.
Get Routing bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.