npm run dev -- --port 3000 &). 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
To whitelist sandbox traffic in your network, you can retrieve the public IP addresses used by Blaxel.
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)
URL prefix
You can customize the preview URL with a custom string prefix using theprefixUrl argument:
https://myprefix-workspace-xxx.preview.bl.run.
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:
When you register a custom domain, you also enable the use of wildcard subdomains for that domain. For example, if you register
mycompany.com, you can configure preview URLs to use any *.mycompany.com subdomain.Using a Webpack server but unable to hot reload your previews? Check our troubleshooting page for possible solutions.
