Utility constant values for getting Vercel Deployment URLs
MIT License
A helper package that determines the Vercel deployment url DEPLOYMENT_URL
at build time. Also provides easier access to Vercel system environment variables. Great for replacing APP_URL
, NEXT_PUBLIC_URL
, or runtime getBaseUrl()
functions where applicable.
npm i vercel-url
or with Bun:
bun i vercel-url
import { DEPLOYMENT_URL } from "vercel-url";
This package determines the DEPLOYMENT_URL
based on the Vercel environment:
VERCEL_PROJECT_PRODUCTION_URL
VERCEL_BRANCH_URL
if available, otherwise VERCEL_URL
http://localhost:3000
VERCEL_BRANCH_URL
will be present.The package provides easier access to the following Vercel system environment variables:
VERCEL_ENV
VERCEL_URL
VERCEL_BRANCH_URL
VERCEL_PROJECT_PRODUCTION_URL
Important Note: These variables are not automatically exposed or leaked when you use this package. They are only accessible if you explicitly import and use them in your code. However, be aware that if your application is bundled (e.g., with Webpack or Rollup), unused exports might still be included in the bundle unless proper tree-shaking is implemented.
process.env
When using this package, keep in mind:
DEPLOYMENT_URL
is doesn't expose the values used to derive it.DEPLOYMENT_URL
, the other Vercel environment variables will not be exposed unless explicitly imported.VERCEL_ENV
, VERCEL_URL
, etc.), ensure you're not unintentionally exposing sensitive information, although these variables are generally safe to use.For more details on Vercel's system environment variables, refer to the official Vercel documentation.