expo-server is a foundational server-side API and runtime library specifically designed for projects leveraging Expo Router. It provides essential utilities and adapters for implementing server-side logic, including API routes, server-side rendering (SSR), and React Server Components (RSC) within a universal Expo application. Functioning primarily in a WinterCG-compliant environment, it allows developers to define API endpoints using a file-based convention (e.g., `+api.ts`), handle HTTP requests, and manage sensitive data securely on the server. The package facilitates full-stack development within the Expo ecosystem, enabling consistent codebases across native, web, and server environments. Expo SDK, which this package is part of or closely aligned with, typically releases new major versions three to four times a year. The current stable version of the broader Expo SDK is 55.x.x, with `expo-server` itself having independent, though generally aligned, releases (e.g., 0.7.5 as seen on npm for `@expo/server`). A key differentiator is its tight integration with Expo Router's opinionated file-system routing and universal development paradigm.
npm install expo-serverVerified import paths — ran on the pinned version, not inferred.
Demonstrates creating a basic server-side API route using `expo-server` within an Expo Router project, including environment checks.
Add `"web": { "output": "server" }` under the `"expo"` key in your `app.json`.Ensure these imports and calls are isolated to files designated as server-side (e.g., `+api.ts` files or React Server Components).
For production, set `"expo": { "extra": { "router": { "origin": "https://your-server.com" } } }`. Remember to remove or conditionally set `origin` for local development if it causes issues.Use server-side API routes to securely handle sensitive environment variables (e.g., API keys) and avoid exposing them to the client bundle. Always prefix client-facing environment variables with `EXPO_PUBLIC_`.
Exercise caution when using RSCs. Test thoroughly, be aware of their limitations, and refer to the latest Expo documentation for best practices and stability notes. Use the 'use client' directive for components requiring client-side interactivity.
Refactor imports to use ES module `import` syntax (e.g., `import { someFunction } from 'some-package';`).Ensure that the corresponding HTTP method (e.g., `export function POST(request: Request) { ... }`) is defined and exported in your `+api.ts` file for the method you are using.Verify `web.output: "server"` is set in `app.json`. For production native builds, set `"expo": { "extra": { "router": { "origin": "https://your-deployed-server.com" } } }` in your `app.json`.Run `npx expo customize tsconfig.json` and ensure you start the development server (`npx expo start`) to generate typed routes. Make sure your `tsconfig.json` includes `expo-router/tsconfig.json`.
No dependency data recorded yet.