Docs

Deploying a site

The CLI writes each host's config (one HTTPS address, security headers, cache), the contact form sender that runs there, and prints the secret and domain steps. With --publish it also runs the host's own CLI, after showing exactly what will run and asking.

The flow

npx vamos-ui site form                 # the contact form sender for this host
npx vamos-ui site deploy --domain ornek.com.tr   # host config + steps + secret commands
npx vamos-ui site deploy --publish      # optional: run the host CLI after a confirmation
npx vamos-ui site check                 # audit + deploy checks on the live address

The host comes from --host, else from the plan in vamos.project.json (npx vamos-ui new asks where the site will run). Neither command replaces a file that already exists, and nothing is published without --publish and your yes.

Hosts

HostBuildConfig writtenContact form
VercelNext.js serververcel.jsonresend or smtp server action
Cloudflare Pagesstatic export (out)public/_headers, public/_redirectsedge: functions/api/contact.ts
Spacefaststatic export, or server on Next 16.2.x / 16.3.x / 15.5.24+public/_headers, public/_redirectsedge: functions/api/contact.ts
NetlifyNext.js serverpublic/_headers, public/_redirectsresend or smtp
cPanel / Pleskstatic export (out)public/.htaccessphp-mail: public/contact.php
VPSNext.js standalone on pm2deploy/nginx-<domain>.conf, deploy/ecosystem.config.cjsresend or smtp

Vercel

  • Import the Git repository (framework: Next.js), or run npx vamos-ui site deploy --publish, which runs npx vercel deploy --prod.
  • vercel.json sends the security headers, caches /_next/static for a year and 301s the other host name.
Vercel Hobby is non-commercial
Vercel's free Hobby plan is for personal, non-commercial use only. A client or business site needs Vercel Pro, or one of the other hosts here.

Cloudflare Pages

Set output: "export" (and images: { unoptimized: true } or a loader) in next.config, then build and upload out/ from the project root, so functions/ deploys with it:

npm run build
npx wrangler pages deploy out --project-name defter-hesap

A site that needs a Next.js server (a shop) deploys as a Worker through the OpenNext adapter instead (@opennextjs/cloudflare); --publish only handles the static export.

Spacefast

sf publish detects a Next.js project, builds it and uploads out. Server rendering works only on the versions its bundled adapter supports; site deploy reads the installed version and picks the mode:

Next.jsServer-renderedWhat site deploy does
16.2.x, 16.3.x, 15.5.24+Yessf publish
14.2, 15.0–15.5.23, 16.0, 16.1, 16.4No (export only)output: "export", build, sf publish ./out --prebuilt
Anything else, prereleasesNobuild the export yourself, sf publish ./out --prebuilt
  • New apps from vamos-ui create depend on next@^16.0.0, which currently installs 16.4, so on Spacefast they publish as a static export. That is what a kit website needs; pin ~16.3.0 yourself only if you need server rendering there.
  • With the edge form, functions/ is copied into out/ before the upload so the /api/contact route publishes with the site.
  • Spacefast reads _headers and _redirects, so the same files as Cloudflare apply. Every plan allows commercial use; the datacenter can be Amsterdam.
  • Publish signed in (sf login). An anonymous, unclaimed Space can only call a short list of APIs, so the form could not reach Resend.

Netlify, cPanel, VPS

These keep their printed steps (no --publish): Netlify imports from Git; on cPanel you upload the contents of out/ to public_html (the .htaccess and contact.php go with it); on a VPS, nginx with a certbot certificate proxies to Next.js on pm2.

Contact form senders

npx vamos-ui site form writes the sender behind ContactForm and one field list shared by the page and the sender. The kind comes from --kind, else the plan, else the project: a static export on Cloudflare Pages or Spacefast gets edge, another static export php-mail, a Next.js server smtp.

KindFileForm actionSends with
edgefunctions/api/contact.ts"/api/contact"Resend HTTP API
php-mailpublic/contact.php"/contact.php"The host's mail server
resendapp/actions/contact.ts{sendContact}Resend HTTP API
smtpapp/actions/contact.ts{sendContact}Your own mailbox (nodemailer)

Every sender validates the same fields, requires the privacy notice (KVKK) consent when the form shows the checkbox, drops honeypot and too-fast submits with a fake success, refuses cross-site posts, rate-limits per IP and puts no visitor input into mail headers except a checked Reply-To.

The edge function

One file runs on both hosts: it exports onRequestPost for Cloudflare Pages Functions and POST for the Spacefast file router, and uses only fetch, Request and Response.

import { contactFields, privacyCheckbox } from "@/app/contact-fields";

<ContactForm
  action="/api/contact"
  fields={contactFields}
  privacyLink={{ href: "/kvkk", label: "KVKK Aydınlatma Metni" }}
  privacyCheckbox={privacyCheckbox}
  turnstileSiteKey={process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY}
/>
AnswerWhen
200 { ok: true, status: "success" }Sent (or a bot was quietly dropped). Without JavaScript: a 303 back to the page with ?vb_sent=<form>.
422 { status: "invalid", errors }A field is missing, too long or malformed, or the consent box is not ticked.
403Cross-site post, or the Turnstile check failed.
429More than 5 messages from one IP in 10 minutes (Retry-After: 600).
400 / 405 / 413 / 415Unreadable body, not a POST, over 32 KB, or an unsupported content type.
500 / 502A secret is not set, or Resend refused the message. The log names the variable, never its value.
The rate limit is best effort
The counter lives in the memory of one running instance, and the platform runs many short-lived instances, so a determined sender can get past it. For a hard limit add a Cloudflare WAF rate-limiting rule for /api/contact, or turn on Turnstile.

Turnstile

Optional, for every sender except php-mail. Create a Turnstile widget for the domain in the Cloudflare dashboard, give the site key to the build as NEXT_PUBLIC_TURNSTILE_SITE_KEY and the secret to the host as TURNSTILE_SECRET. ContactForm loads the Turnstile script only when it has a site key; the sender checks the token with Cloudflare's siteverify API and refuses a submit without one while the secret is set. Turnstile needs JavaScript, so a no-JS submit is refused then.

Secrets

site deploy and site form print the command for each secret. None of them puts the value on the command line: the host CLI asks for it, so it stays out of your shell history. Never commit them.

HostCommand
Vercelnpx vercel env add RESEND_API_KEY production
Cloudflare Pagesnpx wrangler pages secret put RESEND_API_KEY --project-name defter-hesap
Spacefastsf env set RESEND_API_KEY --value-from-stdin --space defter-hesap
cPanelCONTACT_TO / CONTACT_FROM inside public/contact.php (no secret)

The edge and Resend senders read RESEND_API_KEY, CONTACT_TO (comma-separated for several inboxes), CONTACT_FROM (an address on a domain verified in Resend) and the optional TURNSTILE_SECRET; SMTP adds SMTP_HOST, SMTP_PORT, SMTP_USER and SMTP_PASS.

Domain records

HostAdd the domainDNS
VercelProject → Settings → DomainsA 76.76.21.21 for the bare domain, CNAME for www (as Vercel shows).
Cloudflare PagesCustom domainsCreated for you when the zone is on Cloudflare. SSL/TLS: Full (strict), Always Use HTTPS on.
Spacefastsf domains add ornek.com.tr --space defter-hesapThe A / CNAME records it prints; HTTPS is issued automatically.
cPanelAddon domain / the account's main domainThe host's nameservers or A record; AutoSSL before the HTTPS redirect goes live.
VPSnginx server_nameA (and AAAA) to the server; certbot --nginx for the certificate.

Pass --domain (and --www to serve on www) so the redirect from the other host name is written for you.

site deploy --publish

For Vercel, Cloudflare Pages and Spacefast, --publish runs the host's CLI after writing the files. It first shows the host, the project or Space, the directory and every command, then asks (the default answer is no). In CI or another non-interactive run it publishes only with --yes. If the CLI is missing or you are not signed in it prints the install or login command (npx vercel login, npx wrangler login, sf login) and stops.

npx vamos-ui site deploy --host spacefast --space defter-hesap --publish
#  Host:      spacefast
#  Target:    Spacefast Space defter-hesap
#  Directory: out
#  1. npm run build
#  2. cp -R functions out/functions
#  3. sf publish ./out --prebuilt --space defter-hesap
#  ◆ Publish to spacefast now?  No / Yes

npx vamos-ui site deploy --host cloudflare --project defter-hesap --publish --yes   # CI
npx vamos-ui site deploy --publish --dry-run                                       # show the plan only

After the deploy

npx vamos-ui site check runs the audit on the live URL plus the deploy checks: http → https, one host name, the security headers (and every header your public/_headers sets), a real 404, robots.txt and sitemap.xml. With a form sender in the project it also sends an empty POST to its endpoint (/api/contact or /contact.php, or --form-endpoint): a 400, 405, 415 or 422 proves the route is live, a 404 means the function did not deploy. The empty request never passes validation, so nothing is sent. Then send one real message and check the inbox and the spam folder.