✦Morph

CLI reference

The CLI is @usemorph/cli; its command is usemorph. Once Morph is set up in an app, it's installed there, so npx usemorph … works in that folder. Anywhere else, use npx @usemorph/cli ….

init#

npm init usemorph@latest            # same as: npx @usemorph/cli init

Sets Morph up in a Next.js (App Router) app. Shows the plan and the full diff, asks before writing, then signs you in if needed, creates your app and its key, installs the packages and runs sync. See the Quickstart.

Flag
--dry-run Only show the plan and the diff (npm init usemorph@latest -- --dry-run)
--no-ai Plan with built-in rules instead of Morph's AI (nothing is sent)
--yes Don't ask (for scripts). Needs you to be signed in already.
--quiet Don't print the diff

init skips pages that already have a <MorphSurface>, so running it again is safe. Every plan is checked before it's shown: edited files still parse, edits only add Morph's tags, and sync accepts the result.

agent-prompt#

npx @usemorph/cli agent-prompt

Prints instructions for your own coding agent (Claude Code, Cursor…) to set Morph up, for teams that prefer not to send code to Morph's AI.

sync#

npx usemorph sync [--dry-run] [--print]

Reads every <MorphSurface> in your code (its sections, keep rules, layout, and the types of data and actions), plus morph.config.ts, and uploads them. Run it on every deploy. --dry-run shows what it found without uploading; --print also prints the full description. Needs MORPH_SECRET_KEY.

origins#

npx usemorph origins                         # list
npx usemorph origins add https://myapp.com
npx usemorph origins remove https://myapp.com

The websites your app's pages may call Morph from. Needs MORPH_SECRET_KEY.

login, whoami, logout#

npx @usemorph/cli login     # GitHub, in your browser
npx @usemorph/cli whoami    # who you are, and your apps
npx @usemorph/cli logout

login shows a code in your terminal; check that the browser shows the same code before you continue with GitHub. Your sign-in is saved in ~/.config/usemorph/credentials.json, readable only by you. In CI or over SSH, set BROWSER=none and open the printed link yourself.

Environment#

Variable
MORPH_SECRET_KEY Your app's secret key. Read from the environment, then .env.local, then .env.
MORPH_URL Another Morph server (self-hosted or local). Default https://api.usemorph.dev.