--- description: | Fetch data for routes dynamically by creating a custom handler and passing data to the render function. --- All of the pages in the demo project so far have not used any dynamic data during rendering. In real projects, this is often different. In many cases you may need to read a file from disk (e.g. markdown for a blog post), or fetch some user data from an API or database. In order to fetch data, the route component must be asynchronous. The first parameter contains the client's [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) object. The second `ctx` parameter is used to get the route parameters. Here is an example of a route that fetches user data from the GitHub API and renders it in a page component. ```tsx routes/github/[username].tsx import { RouteContext } from "$fresh/server.ts"; interface GitHubResponse { login: string; name: string; avatar_url: string; } export default async function Page(_req: Request, ctx: RouteContext) { const resp = await fetch( `https://api.github.com/users/${ctx.params.username}`, ); if (!resp.ok) { return
{login}