How to Deploy a Distlang Worker with CLI: Get a Hosted URL
What This Guide Covers
If you want to know how to deploy a Distlang worker with the CLI and get a hosted URL, you’re in the right place. This is a glossary-style walkthrough organized in the order you’ll encounter each concept: from installing the CLI, through building and testing locally, to deploying and receiving a live URL.
The full flow in one sentence: install the Distlang CLI, write a worker, build it, run it locally, deploy it, and get a hosted URL back in your terminal.
New to the platform? Start there for background, then come back here for the deploy workflow.
The Tools
Distlang CLI
The distlang CLI is the single tool that handles the entire build, run, and deploy lifecycle for Distlang workers. It compiles JavaScript worker applications, runs them locally using the workerd runtime, and packages them for deployment to either Cloudflare or Distlang’s own hosted infrastructure.
You can grab released binaries from the public GitHub repository (v0.1.3 as of April 2026). Once installed, the CLI exposes three core subcommands: build, run, and deploy. This three-verb pattern mirrors what most modern developer CLIs have converged on. Cloudflare’s Wrangler uses dev and deploy, Vercel’s CLI deploys with a single command, and Trigger.dev’s CLI compiles and deploys in one step. The industry expectation is clear: type a command, get a URL.
The difference with Distlang is that the CLI handles compilation itself rather than just uploading pre-built artifacts. When you run distlang build, it compiles your worker code and any imported helpers into a deployable bundle. This is worth understanding because it means the CLI is doing more than a simple file upload.
workerd (Local Runtime)
workerd is the open-source Cloudflare Workers runtime. It’s the same engine that runs Workers in production on Cloudflare’s network. Distlang uses workerd for local development, which means the code you test on your machine behaves identically to what runs after deployment.
Cloudflare’s own documentation explains that developers can build, run, and test Worker code locally before deploying to production. Distlang follows the same principle. When you run distlang run, it starts a local workerd server so you can preview and test your worker without deploying anything.
This production parity matters. If your worker uses features like waitUntil() for flushing metrics or performing background tasks, those behave the same locally as they do in production. For more on this, see the guide on waitUntil patterns for workerd.
Node.js Prerequisite
The Distlang CLI requires Node.js to be installed on your machine. This is standard across most JavaScript toolchains and shouldn’t surprise anyone working with Workers.
The Application
Distlang Worker
A Distlang worker is a JavaScript application compiled and deployed through the Distlang CLI. It runs on the Cloudflare Workers runtime (workerd) both locally and in production.
This distinction matters: a Distlang worker is not exactly the same thing as a plain Cloudflare Worker. It’s a superset. The Distlang CLI compiles the application, bundles any imported helpers and layers, and handles deployment configuration. A raw Cloudflare Worker deployed through Wrangler doesn’t have access to Distlang’s helpers model or its hosted deploy infrastructure.
Think of it this way: every Distlang worker runs on the Cloudflare Workers runtime, but not every Cloudflare Worker is a Distlang worker. The Distlang tooling adds compilation, helpers, and the hosted deploy option on top of the base runtime.
If you want to build your first one from scratch, the hello world tutorial walks through the entire process.
Helpers
Helpers are reusable application capabilities that you import directly into your worker code. Examples include ObjectDB for storage and the metrics client for instrumentation. Instead of wiring up separate services, configuring API keys for each one, and writing glue code, you import a helper and use it.
When you run distlang build, helpers get bundled into the compiled artifact along with your application code. This means everything your worker needs travels together as a single deployable unit.
For a deeper explanation of the concept, read what helpers are in Distlang.
Layers
Layers are the composition model that makes helpers work. Instead of manually assembling infrastructure components (a database here, a metrics pipeline there, an auth service somewhere else), you compose your app from layers that provide those capabilities.
The practical implication for deployment is straightforward: layers determine what gets included in your build. When you import a metrics layer, the build step compiles that capability into your worker. When you deploy, everything goes together. There’s no separate infrastructure to provision for each layer.
For the full picture on how composition works, see the guide on simple app layering.
The Lifecycle Commands
These three commands are the core of how to deploy a Distlang worker with the CLI and get a hosted URL. They map directly to the development lifecycle.
distlang build
What it does: Compiles your JavaScript worker application into a deployable artifact.
This is the compilation step. The CLI takes your source code, resolves any imported helpers or layers, and produces a bundle that’s ready to run locally or deploy. Unlike some tools that auto-detect frameworks and skip an explicit build step, Distlang always compiles through its own pipeline. This gives it control over how helpers are resolved and bundled.
When to run it: Before distlang run (for local testing) or before distlang deploy (for deployment). Some developers run build as a CI check to catch compilation errors early.
distlang run
What it does: Starts a local workerd server running your compiled worker.
After building, distlang run lets you test your worker on your own machine. Requests to localhost hit the same workerd runtime that production uses, so behavior should match. This is the place to verify that your handlers return correct responses, that your helpers work as expected, and that any metrics instrumentation flushes properly.
For a dedicated walkthrough of local debugging, check out the guide on using the CLI to run and debug workers locally.
distlang deploy
What it does: Packages your compiled worker and uploads it to a deploy target. Returns a live URL.
This is the command that answers the core question: how to deploy a Distlang worker with the CLI and get a hosted URL. Running distlang deploy sends your built artifact to Distlang’s hosted infrastructure and prints a *.distlang.com URL in your terminal. That URL is immediately live and shareable.
The deploy step is intentionally simple. As one practitioner observed in a widely cited overview of serverless deployment, “each provider has its own method to deploy serverless functions. However, deployment is the easiest part. It’s the provider setup and the function’s code that takes the most time to prepare.” Distlang’s approach reflects this: the build and helpers do the heavy lifting, and deploy is the simple final step.
Authentication and Configuration
API Token
Distlang uses a single long-lived API token per account. The CLI uses this token during the deploy step to authenticate with Distlang’s infrastructure.
The model is intentionally minimal. You don’t manage multiple API keys, rotate short-lived tokens, or configure OAuth flows. One token, one account. This simplicity is a deliberate trade-off that works well for small teams and individual developers who don’t want credential sprawl across their projects.
You’ll set this token before your first deploy, and then the CLI handles authentication automatically on subsequent deployments.
Get your API token and start deploying through the documentation portal.
Deploy Target
The Distlang CLI supports two deploy targets:
Distlang-hosted (managed subdomain): Your worker deploys to Distlang’s infrastructure and receives a *.distlang.com URL. No Cloudflare account needed. No DNS configuration. This is the default simple path for getting a hosted URL.
Cloudflare (your own account): For production workloads, you can deploy directly to your Cloudflare account with custom domains. This gives you full control over routing, DNS, and Cloudflare-specific features.
This dual-target model is a differentiator. For comparison, Cloudflare’s Wrangler recently introduced wrangler deploy --temporary as a special flag for deploying before authentication is fully configured. That flow creates a temporary preview account and prints a claim URL. Distlang’s hosted deploy is simpler: it’s the default path, not a special flag, and the resulting URL is yours immediately without a separate claim step.
The Output
Hosted Deploy URL
This is what you’re here for. When you run distlang deploy targeting the hosted infrastructure, the CLI returns a managed *.distlang.com subdomain. That URL is live immediately. You can open it in a browser, share it with teammates, or point integration tests at it.
When to use hosted deploy URLs:
- Demos: Share a working version of your app without provisioning any infrastructure.
- Staging: Test against a live environment before promoting to production on your own Cloudflare account.
- Quick tests: Verify that something works end-to-end without committing to a full deployment pipeline.
The expectation that a CLI deploy command should return a shareable URL is now standard across the industry. Netlify pioneered the pattern of deploying every commit to a unique URL, which practitioners widely credit with making it dramatically easier to test new features. Vercel’s CLI outputs a deployment URL immediately. Distlang’s hosted deploy URLs meet this same standard.
For a deep dive on use cases and patterns, read using hosted deploy URLs for demos and staging.
Custom Domain (Cloudflare Deploy)
When you’re ready for production, deploy to your own Cloudflare account instead. This lets you use custom domains, configure Cloudflare-specific routing rules, and manage your worker alongside your other Cloudflare resources.
The hosted URL and the Cloudflare deploy are not mutually exclusive. Many developers use hosted URLs during development and switch the deploy target when the app is ready for production traffic.
Quick Reference: Deploy a Distlang Worker and Get a Hosted URL
| Step | CLI Command | What Happens | Output |
|---|---|---|---|
| 1. Install | Download from GitHub | CLI binary available on your PATH | distlang command accessible |
| 2. Write code | (your editor) | Create a JS worker with handlers and helpers | Source files in project directory |
| 3. Build | distlang build |
Compiles JS + helpers into a deployable artifact | Built bundle ready for run or deploy |
| 4. Test locally | distlang run |
Starts local workerd server | localhost URL for preview |
| 5. Authenticate | Set API token | CLI stores your account credential | Token configured |
| 6. Deploy | distlang deploy |
Packages and uploads to Distlang-hosted infra | Live *.distlang.com URL printed to terminal |
This table captures the entire process of how to deploy a Distlang worker with the CLI and get a hosted URL. Six steps, three CLI commands, one live URL at the end.
Side-by-Side: Distlang CLI vs. Wrangler
If you’re coming from Cloudflare’s Wrangler, this mapping will orient you quickly:
| Wrangler | Distlang CLI | Notes |
|---|---|---|
wrangler dev |
distlang run |
Both use workerd locally |
wrangler deploy |
distlang deploy |
Wrangler outputs *.workers.dev; Distlang outputs *.distlang.com |
wrangler deploy --temporary |
distlang deploy (hosted target) |
Distlang’s hosted deploy is the default, not a special flag |
| Framework auto-detection | distlang build (explicit compilation) |
Distlang always compiles through its own pipeline |
| Bindings (KV, D1, etc.) | Helpers and layers | Different names for the concept of attaching capabilities to a worker |
The core workflows are parallel. The biggest difference is that Distlang bundles compilation, helpers, and hosted deployment into a single tool rather than relying on Cloudflare’s dashboard or bindings configuration.
Instrumenting Your Deployed Worker
Once your worker is live on a hosted URL, you’ll probably want to know what it’s doing. Distlang Metrics lets you add counters and histograms directly in your worker code, with data flowing to a hosted dashboard at dash.distlang.com.
The metrics helper is one of the capabilities you can import as a layer. After deployment, your worker can flush metrics using ctx.waitUntil() patterns that work correctly in short-lived serverless handlers.
Start with the metrics quickstart to add instrumentation to your deployed worker.
For guidance on getting counters and histograms right, the article on instrumenting Cloudflare Workers covers the patterns in detail.
FAQ
Is a Distlang worker the same as a Cloudflare Worker?
Not exactly. A Distlang worker runs on the Cloudflare Workers runtime (workerd), so at the runtime level they’re compatible. But a Distlang worker is compiled through the Distlang CLI, can import Distlang helpers and layers, and can be deployed to Distlang’s hosted infrastructure. Think of it as a Cloudflare Worker with additional tooling and capabilities layered on top.
Do I need a Cloudflare account to deploy a Distlang worker and get a hosted URL?
No. The hosted deploy path uses Distlang’s own infrastructure. You run distlang deploy, and you get a *.distlang.com URL without touching Cloudflare’s dashboard or configuring any account. A Cloudflare account is only needed if you choose to deploy to your own Cloudflare infrastructure for production.
Can I use the hosted URL in production?
Hosted deploy URLs are designed for demos, staging, and quick tests. For production traffic with custom domains and full routing control, deploy to your own Cloudflare account using the CLI’s Cloudflare deploy target.
What authentication does the CLI need?
A single long-lived API token per account. You configure it once, and the CLI uses it for all subsequent deploys. There’s no multi-key management or token rotation to worry about.
How is this different from Wrangler’s temporary deploy?
Wrangler introduced --temporary as a special flag that creates a temporary preview account and requires a separate claim step. Distlang’s hosted deploy is the default simple path, not a special mode. The resulting *.distlang.com URL is yours immediately without extra steps.
What gets included in the deployed bundle?
Your JavaScript worker code plus any helpers and layers you’ve imported. The distlang build step compiles everything into a single artifact, and distlang deploy uploads that artifact. There’s no separate infrastructure to provision for helpers like ObjectDB or metrics.
Do I need to run build before deploy?
Yes. The Distlang CLI uses an explicit compilation step. Running distlang build creates the artifact that distlang deploy uploads. This is different from tools that auto-detect and compile during the deploy step.
Where can I see the full documentation?
The Distlang docs hub covers everything from CLI commands to metrics integration. For a complete walkthrough from writing code to seeing a dashboard, follow the end-to-end example.