Expo Router provides a powerful way to create API endpoints directly within your app directory, allowing you to write server-side code that works seamlessly across all platforms (iOS, Android, and web).

Example

// app/api/hello+api.ts
 
/**
 * GET method for the /api/hello route
 */
export function GET(request: Request) {
  return Response.json({ message: "Code with Beto! 🚀" });
}
 
/**
 * POST method for the /api/hello route
 */
export function POST(request: Request) {
  const { name } = await request.json();
  return Response.json({ message: `Hello, ${name}!` });
}

Learn More

Is this lesson useful?