Routing
87 bites tagged Routing — interview questions with model answers, and 60-second explainers.
Next.js Intercepting Routes: Modals on Rails
Intercepting routes let you show one route's content inside another's layout, like a photo modal over a gallery feed. It's ideal for shareable modal URLs. The footgun: a page refresh or direct navigation bypasses the interception, rendering the full page.
Next.js Parallel Routes: Multiple Pages in One View
Parallel Routes render multiple independent pages within a single layout, like a split-screen dashboard. This is ideal for complex UIs where different sections need to load and be managed separately.
Next.js Route Groups: Invisible Folders for Routes
Route Groups are invisible folders for your Next.js routes, letting you organize files without changing the URL. Use them to apply a specific layout to a set of pages, like a marketing section vs. a user dashboard.
next/link: Fast, Client-Side Navigation
next/link is an enhanced `<a>` tag for fast, client-side page transitions, preserving the SPA feel. It automatically prefetches linked pages for instant loading.
Next.js: Pages Router vs. App Router
The App Router treats UI as a tree of components, while the older Pages Router treats it as a collection of separate pages. Use App Router for new projects to leverage layouts and Server Components.
useRouter: Programmatic Navigation in Next.js
The useRouter hook gives you a router object to programmatically control navigation. Use it for event-driven redirects, like sending a user to their dashboard after a successful login.
Next.js Dynamic Routes: Pages on Demand
Think of dynamic routes as a page template. You create one file like `[slug].js` to generate unlimited unique pages for things like blog posts or products. The footgun is forgetting to handle non-existent slugs, which can crash your app.
Nested Routes: Composing UI with <Outlet>
Nested routes build layouts with shared UI, like a sidebar. The <Outlet> component is a placeholder for changing content, perfect for dashboards. The footgun is forgetting the <Outlet> in the parent route; child routes will match the URL but won't render.
Next.js Layouts: Shared UI That Survives Navigation
Think of a Next.js Layout as a picture frame that stays put while you swap the pictures (Pages) inside. It defines shared UI like headers that persist across routes, preserving state.
FastAPI: Splitting Your App with `include_router`
`app.include_router` is like plugging a pre-wired power strip of API endpoints into your main FastAPI app. It lets you organize a large app into smaller files by feature, then combine them. The footgun is forgetting to add a URL `prefix` for each router.
FastAPI's APIRouter: Grouping Routes into Modules
Think of APIRouter as a mini-FastAPI app for organizing endpoints. It lets you group related paths, like all user routes, into a separate file. This is crucial for keeping large applications maintainable.
express.Router: Group Routes into Modular Files
express.Router is a mini-app for your routes. It lets you group related endpoints (e.g., all `/users/...` routes) into their own file, keeping your main `app.js` clean. The footgun is forgetting to mount the router in the main app with `app.use()`.
Express.js: Basic Request Routing
Express routing connects a request's path and HTTP method (like GET `/`) to a specific handler function. This is the core of any Express app, used to define API endpoints or handle form submissions. A common mistake is using the wrong method for a request.
Flutter's onGenerateRoute for Dynamic Routes
onGenerateRoute is Flutter's central switchboard for creating routes on the fly, especially when they need data. Use it to pass arguments to new screens or handle routes not statically defined in the `routes` map.
Flutter Named Routes: Navigate with Strings, Not Widgets
Think of named routes as URL paths for your app's screens. Instead of building a screen widget on the spot, you just tell Flutter "go to '/profile'". This is ideal for centralizing navigation in large apps and for enabling deep linking.
Get Routing bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.