skip to content

Web Output & API Routes

web.output picks a single-page, static or server build, and +api files add HTTP handlers beside the screens. Interviewers ask how the same file tree becomes web URLs and native deep links.

part ofExpo (React Native)overview, primer and where to startread it →
on this pageshow

explore

questions

5

With Expo Router API routes, how do you add a waitlist signup endpoint, and what keeps its API key out of the app bundle?

level: middleimportance: should knowfreq 35%

basics

~20 s

Create src/app/api/waitlist+api.ts exporting a POST(request) function that returns a Response, with web.output set to server. Code only API routes import runs on the server and is stripped from the client bundle, so the key stays server-side.

open as a page

In an Expo Router project, what do the web.output values single, static and server produce, and which suits a marketing site?

level: middleimportance: should knowfreq 40%

basics

~20 s

single exports one index.html for a client-rendered SPA, static renders an HTML file per route at export time, and server adds a server bundle for API routes. A marketing site wants static, or server once it has its own endpoints.

open as a page

In an Expo Router web build, what is src/app/+html.tsx for, and why can it not read window or host context providers?

level: middleimportance: nice to knowfreq 15%

basics

~20 s

+html.tsx customises the root HTML document that wraps every statically rendered page. It runs only in Node.js at render time, so window is undefined there, and providers belong in the root layout, which runs in the app.

open as a page

In an Expo Router app, fetch('/api/waitlist') works in development but fails in the native release build; why, and how do you fix it?

level: seniorimportance: nice to knowfreq 22%

basics

~20 s

In development relative URLs resolve to the Expo dev server, which runs API routes. A release build has no dev server, so the server must be deployed and its URL set as the expo-router plugin's origin before building.

open as a page