Skip to main content
This tutorial explains how to run an Expo (React Native / Web) application inside a Blaxel sandbox and expose it securely using sandbox preview URLs.

Prerequisites

  • Blaxel CLI installed and authenticated (bl login)
  • Node.js 18+ installed
  • @blaxel/core package installed in your project (npm install @blaxel/core)

Architecture overview

Running Expo inside a Blaxel sandbox requires a few adjustments:
  1. Injecting the preview URL into app.json
  2. Setting EXPO_PACKAGER_PROXY_URL to force Expo to proxy assets through the preview URL
  3. Restarting the dev server after configuration changes
  4. Exposing the Expo dev server via a Blaxel preview URL

Create a base sandbox image

Dockerfile

blaxel.toml

Create a blaxel.toml file in the same directory as your Dockerfile:

Deploy the sandbox image

Deploy the image by running:

Create or reuse a sandbox

Create a sandbox from the base image:

Configure CORS for preview URL access

Expo servers require permissive CORS headers when accessed through a preview URL:
Alternatively, you can use custom domains to expose previews on your own domain.

Create the preview URL

Expo runs on port 8081, so expose that port via a preview URL:

Generate a preview token

To securely access the preview, a token is required:

Inject the preview URL into Expo’s app.json

The Expo application router requires the correct origin when running behind a proxy:

Configure the proxy URL

Expo must be configured to serve assets through the preview URL. This function checks if the configuration is already correct and only updates if needed:

Start the dev server

After setting the proxy URL you can start the dev server:

Stream logs

Monitor the Expo server output in real-time:

Access the Expo application

Once everything is running, the Expo application will be available at https://<PREVIEW-URL>?bl_preview_token=<TOKEN>

Complete example

Here is a full example combining all the steps:
Last modified on May 14, 2026