npm run dev). This preview URL can be either public (does not require you to be authenticated to access it) or private (see down below).
They will look something like this:
Current limitations of real-time previews
JavaScript module bundlers handle real-time previewing. Here are the key compatibility requirements and limitations:- Module bundler must implement ping-pong
- Webpack has been tested and works
- Turbopack currently doesn’t work as it doesn’t support ping-pong (see issue raised to Vercel)
- Blaxel has a 15-minute connection timeout. To maintain previews beyond this limit, ensure your bundler implements automatic reconnection
- You cannot create a preview on port 80 which is reserved for system
Private preview URLs
When you create a private preview URL a token is required to access the URL. You must include the token as:- a
bl_preview_tokenquery parameter when accessing the preview URL (e.g. https://tkmu0oj2bf6iuoag6mmlt8.preview.bl.run/health?bl_preview_token={token.value}) - a
X-Blaxel-Preview-Tokenheader
Manage preview URLs
Blaxel console
You can create a preview URL for a sandbox from the Blaxel Console, on the overview of a sandbox:
Blaxel SDK
Set up authentication to Blaxel
Set up authentication to Blaxel
The Blaxel SDK authenticates with your workspace using credentials from these sources, in priority order:
- when running on Blaxel, authentication is handled automatically
- variables in your
.envfile (BL_WORKSPACEandBL_API_KEY, or see this page for other authentication options). - environment variables from your machine
- configuration file created locally when you log in through Blaxel CLI (or deploy on Blaxel)
Create if not exists
Just like for sandboxes, this helper function either retrieves an existing preview or creates a new one if it doesn’t exist. Blaxel first checks for an existing preview with the providedname and either retrieves it or creates a new one using your specified configuration.
Custom domains
To set up a custom domain for your sandbox preview:- Register a custom domain to your Blaxel workspace and complete the verification process
- Use this verified custom domain when creating a new preview:
Troubleshooting
Cannot hot-reload on Webpack preview
If you’re running a Webpack server and can’t connect to it via WebSocket from your client (for hot reloading the preview), the issue is likely that you’re trying to connect to the same port you use in local development—but the preview URL is already pointing to a different port on your sandbox. To fix this, add a conditional in thewebSocketURL of your webpack/config.dev.js to handle the different ports:
