Dual-Domain Setup
Pay4SaaS supports running two independent sites from one codebase — for example, an international site (example.com) and a domestic China site (example.cn). Everything is controlled via environment variables with zero code changes.
How It Works
Each domain is a separate deployment with its own .env file. The key environment variable is NEXT_PUBLIC_LOCALE_SITE:
- Primary site (e.g.
.com):NEXT_PUBLIC_LOCALE_SITEis not set - Secondary site (e.g.
.cn):NEXT_PUBLIC_LOCALE_SITE=cn
# Primary site (.com) — no NEXT_PUBLIC_LOCALE_SITE
NEXT_PUBLIC_SITE_URL=https://www.example.com
NEXT_PUBLIC_PAYMENT_PROVIDERS=stripe,paypal
# Secondary site (.cn) — set NEXT_PUBLIC_LOCALE_SITE
NEXT_PUBLIC_LOCALE_SITE=cn
NEXT_PUBLIC_SITE_URL=https://www.example.cn
NEXT_PUBLIC_PAYMENT_PROVIDERS=alipayWhat Changes
Triggered by NEXT_PUBLIC_LOCALE_SITE=cn (value is cn)
| Area | Primary Site | Secondary Site (cn) |
|---|---|---|
| Currency | USD ($) | CNY (¥) |
| Prices | amount / price | amountCNY / priceCNY |
| Default language | English | Chinese |
| Terms / Privacy | English version | Chinese version |
| ICP filing badge | Hidden | Shown (if NEXT_PUBLIC_ICP_BEIAN is set) |
| Trial period | Enabled | Disabled |
Triggered by NEXT_PUBLIC_LOCALE_SITE existing (any value)
As long as this variable is set — regardless of what the value is — the site is treated as a secondary site, and SEO is fully disabled:
| Area | Primary Site | Secondary Site |
|---|---|---|
robots.txt | Allow: / | Disallow: / |
| Sitemap | Full sitemap | Empty |
| Meta robots | Not set | noindex, nofollow |
This means only your primary domain gets indexed by search engines.
Environment Variables That Differ
| Variable | Primary (.com) | Secondary (.cn) | Purpose |
|---|---|---|---|
NEXT_PUBLIC_LOCALE_SITE | (not set) | cn | Enable secondary site mode |
NEXT_PUBLIC_SITE_URL | https://www.example.com | https://www.example.cn | Base URL for links, sitemap, OG tags |
NEXT_PUBLIC_PAYMENT_PROVIDERS | stripe,paypal,creem | alipay | Which payment buttons to show |
NEXT_PUBLIC_PRICING_MODEL | Your choice | Your choice | Can be different per domain |
NEXT_PUBLIC_ICP_BEIAN | (not set) | Filing number | China ICP filing badge |
NEXT_PUBLIC_CONTACT_EMAIL | International email | Domestic email | Shown on contact pages |
Payment provider secrets (Stripe keys, Alipay keys, etc.) should only be set on the deployment that uses them.
Local Development
Use npm run dev:cn to preview the secondary site locally. This loads .env.local.cn which sets NEXT_PUBLIC_LOCALE_SITE=cn.
npm run dev # Preview as primary site
npm run dev:cn # Preview as secondary sitePricing Configuration
In config/payment.ts, each plan supports dual pricing:
basic: {
amount: 9.99, // USD — used on primary site
amountCNY: 29, // CNY — used on secondary site (cn)
// ...
}If amountCNY is not set, the secondary site falls back to the USD price.
Shared Database
Both deployments can share the same Supabase database. User accounts, subscriptions, and usage data are shared across domains. Cookie domain is automatically extracted from NEXT_PUBLIC_SITE_URL to ensure proper session handling.
Deployment
Each domain needs its own deployment (e.g. two Vercel projects, or one Vercel + one VPS). The only difference is the environment variables — the code is identical.
- Deploy the primary site with your primary
.env - Deploy the secondary site with
NEXT_PUBLIC_LOCALE_SITE=cnand secondary-specific env vars - Both deployments point to the same Git repo and same branch