Deploying
Morph works the same in production as on your machine. Three things to set up once.
1. Your secret key on your host#
Add MORPH_SECRET_KEY to your hosting provider's environment variables, with the value from .env.local.
- Vercel: Project → Settings → Environment Variables →
MORPH_SECRET_KEY, for Production (and Preview if you want Morph there), then redeploy. - Netlify, Render, Railway, Fly…: the same, in their environment settings.
Keep it server-only: never prefix it with NEXT_PUBLIC_.
2. Allow your website#
Morph only answers browsers on websites you've allowed. init allows local development (any localhost port) and the live address you give it. Add others:
npx usemorph origins add https://your-app.com
npx usemorph origins # list them
npx usemorph origins remove https://old.your-app.com
Use the exact address in the browser's address bar, without a path: https://your-app.com, https://www.your-app.com and https://your-app.vercel.app are three different origins. Preview deployments with changing addresses need each address added; most teams only enable Morph in production. If Morph isn't showing on a site, the browser console says which address to add.
3. Sync on every deploy#
usemorph sync tells Morph what's on your pages: the sections, the layout, the types of your data. Run it whenever they change, ideally on every deploy:
// package.json
"scripts": {
"build": "next build && usemorph sync"
}
or in CI:
- run: npx usemorph sync
env:
MORPH_SECRET_KEY: ${{ secrets.MORPH_SECRET_KEY }}
sync needs MORPH_SECRET_KEY (from the environment or .env.local). It uploads descriptions only, never your code files or data.
Several environments#
One Morph app can serve several websites: allow each one with origins add (for example your staging and production addresses). They share the same saved pages per user id. Separate apps per environment are on our list.