Custom Domains & Hosting
Custom Domains
You can configure a custom domain, like api.example.com
, to serve HTTP actions
or Convex functions from your production Convex deployments. The settings for
this feature are accessed through the Project Settings page on any of your
projects.
After you enter a domain, you will be shown which records to set on your DNS provider. Some popular DNS providers that you can use to buy a domain are Cloudflare and GoDaddy. We will verify your domain in the background, and once these records are set, you will see a green checkmark.
When you see that checkmark, your backend will now serve traffic from that domain. The first request may take up to a minute because Convex will have to mint a new SSL certificate.
Reach out to support@convex.dev if you have any questions about getting set up!
Custom domains require a Convex Pro plan. Learn more about our plans or upgrade.
Hosting with a Custom Domain
To use a custom domain to serve your Convex functions, there's an additional
step: override the CONVEX_CLOUD_URL
environment variable.
Then re-deploy your project. This may entail clicking "Redeploy" in Vercel or
Netlify, or directly running npx convex deploy --cmd 'npm run build'
. The
newly deployed code will access your Convex functions through your custom
domain.
The CONVEX_CLOUD_URL
environment variable is used in several places:
npx convex deploy --cmd '...'
setsCONVEX_URL
(or similarly named) for your frontend to connect websockets and HTTP clients- In your Convex functions, it is available as
process.env.CONVEX_CLOUD_URL
- File storage URLs:
ctx.storage.getUrl(id)
andctx.storage.generateUploadUrl()
- Generate an OpenAPI spec with
npx convex function-spec --prod
You may also override the CONVEX_SITE_URL
environment variable to be a custom
HTTP Action domain.
- In your Convex functions, it is available as
process.env.CONVEX_SITE_URL
- It may be used for webhooks
- It may be used in
auth.config.ts
as theissuer
for Convex Auth
Custom Hosting
If you're using only Convex for backend functionality you can host your web app on any static hosting provider. This guide will use GitHub Pages as an example.
If you're using Next.js or other framework with server functionality you'll need to use a provider that supports it, such as Netlify or Vercel. You can still host Next.js statically via a static export.