Base URL

What is the Base URL? Changing the Base URL (aka Public Base Path) is about changing the "URL pathname root" of our app. For example, instead of deploying our app to* (base: /) we can change the Base URL and deploy it to* (base: /some/base/url/).

To change the Base URL we:

  1. Add the base config to both vite.config.js#base and createPageRenderer({ base }). Example: /examples/base-url/vite.config.js and /examples/base-url/server/server.js.

  2. Use the import.meta.env.BASE_URL value injected by Vite to construct a <Link> component that prepends the Base URL. Example: /examples/base-url/components/Link.jsx.

  3. Use import.meta.env.BASE_URL when referencing static assets living in public/. Example: /examples/base-url/renderer/


We can set base to '' (for cross-origin deployments) or to './' (for embedded deployments at multiple paths).

See also: