Getting Started

Local setup and the day-to-day commands for the Landing (swapps-campaigns) site.

Prerequisites

  • Node.js >=22.12.0 (see engines in package.json; an .nvmrc pins the version — run nvm use).
  • npm (the repo ships a package-lock.json).

Install

cd swapps-landing
npm install

Git hooks are wired on install

The prepare script runs git config core.hooksPath .githooks, which enables the pre-push gate (type-check + e2e). Run npm install once after pulling the repo so the hook is active. See Testing → Pre-push gate.

Run the dev server

npm run dev          # Vite dev server (SSR) at http://localhost:3100

Open a landing by its slug, e.g. http://localhost:3100/website-support or the Spanish version at http://localhost:3100/es/website-support/.

Scripts

All scripts come from package.json.

Script Command What it does
npm run dev vite dev --port 3100 Vite dev server with SSR on port 3100.
npm run build vike build Prerenders every landing to static HTML in dist/client/.
npm run preview npm run build && wrangler pages dev dist/client Builds, then serves locally as Cloudflare Pages would.
npm run deploy npm run build && wrangler pages deploy Builds and deploys to Cloudflare Pages. See Deployment.
npm run type-check tsc --noEmit TypeScript type-check, no emit.
npm test npm run type-check && npm run test:e2e Type-check + the automatic e2e suite.
npm run test:e2e playwright test Automatic Playwright suite (stubs reCAPTCHA + mocks leads).
npm run test:e2e:ui playwright test --ui Same suite in Playwright's UI mode.
npm run test:e2e:manual node scripts/form-e2e-manual.mjs Headed manual walkthrough that hits the real worker.
npm run prepare git config core.hooksPath .githooks Wires the pre-push hook (runs automatically on install).

First-time Playwright run also needs the browser binary once:

npx playwright install chromium

Environment variables

All values are public — they are inlined into the client bundle at build time, so never put secrets or API tokens here. Copy .env.example to .env for local overrides. Defaults are defined in vite.config.ts.

Variable Required Default (from vite.config.ts) Purpose
BASE_URL No https://go.swapps.com Canonical origin for <link rel="canonical">, Open Graph URLs, and absolute OG image URLs.
API_URL No https://swapps-worker.swapps.workers.dev swapps-worker base URL for lead submission (/api/support/send).
RECAPTCHA_SITE_KEY For real submits (a default v2 key) reCAPTCHA v2 site key (same as swapps-client). Required for submissions to reach the worker.
GTM_ID No GTM-WBC6V37 Google Tag Manager container. Set to an empty string to inject nothing.
GTAG_ID No "" (disabled) Optional Google Ads / GA4 gtag.js ID.
LEADS_ENDPOINT No "" (off) Optional override: POST the raw lead payload to a custom CRM / n8n / Zapier / own API instead of swapps-worker.
NODE_ENV No Vite mode Standard build mode.

Local lead submission

With no RECAPTCHA_SITE_KEY configured, submitLead() logs the payload and resolves OK without calling the worker — so local development never creates real Pipedrive leads. See Architecture → Leads.