# package.json embed

> Configure routeup inside an existing package.json under the routeup key.

Node projects can keep routeup config in `package.json` under a top-level
`routeup` key. Routing fields are shared with
[`routeup.json`](/docs/configuration/routeup-json), but runner configuration is
source-specific: a `package.json` embed selects a package script with `script`,
while standalone `routeup.json` uses `command`.

## Example

```json title="package.json"
{
  "name": "example-app-web",
  "scripts": {
    "dev": "routeup",
    "dev:app": "vite"
  },
  "routeup": {
    "name": "example-app",
    "script": "dev:app"
  }
}
```

Here `npm run dev` launches `routeup`, which runs your real dev server
(`dev:app`) behind `https://example-app.localhost` and injects `PORT`, `HOST`,
`ROUTEUP_LOCAL_URL`, and `ROUTEUP_URL`. In local-only runs, `ROUTEUP_URL` is the local URL; when public exposure is enabled, it becomes the public URL. See the bare
[`routeup`](/docs/cli-reference/routeup) command for the script-runner flow.

## The routeup block

```txt
name          optional default route name (separate from the package's own name)
port          local port to proxy to
script        package script to run in script-runner mode
port_env_var  additional environment variable that receives the assigned port
targets       optional list of path-routed targets for one-origin frontend + API setups
expose        optional public exposure settings, including paths
capture       optional request/response capture settings for routeup inspect
```

`command` is not valid inside the `package.json` `routeup` block. Define the
command in `scripts` and reference that script by name with `routeup.script`.
When set, `port_env_var` receives the same value as `PORT`; it cannot name
Routeup-managed variables, `HOST`, `PATH`, or `NODE_EXTRA_CA_CERTS`.

The `routeup.name` is independent of the package's `name` field, the package can
be `example-app-web` while the route is `example-app`. If `routeup.name` is
omitted, bare runner mode uses `ROUTEUP_NAME` and then the working-directory
basename.

## Precedence

If a directory has both a `routeup.json` and a `package.json` `routeup` block,
`routeup.json` wins. Config is discovered in the current working directory only.

## Why embed

For a JS project you already have a `package.json`. Adding a `routeup` block (and
pointing a `dev` script at `routeup`) is the lowest-friction way to give the
project a stable route that travels with the repo.
