Next.js website for Swift Ridge Law with a Cloudflare Pages contact function powered by Resend.
npm install
npm run devOpen http://localhost:3000 with your browser.
The contact form posts to /api/contact, which is implemented as a Cloudflare Pages Function in functions/api/contact.ts. The Resend API key must be configured in Cloudflare, not committed to GitHub.
In Cloudflare Pages, open this project and go to:
Settings -> Environment variables
Add these production variables:
RESEND_API_KEY=re_your_resend_api_key
CONTACT_TO_EMAIL=sarthakbohora1@gmail.com
CONTACT_FROM_EMAIL=Swift Ridge Law <onboarding@resend.dev>For production sending from the law firm's domain, verify the domain in Resend and then change CONTACT_FROM_EMAIL, for example:
CONTACT_FROM_EMAIL=Swift Ridge Law <contact@swiftridgelaw.com>After adding or changing environment variables in Cloudflare, redeploy the Pages project.
Use the existing Cloudflare Pages Git integration for the sarthak branch.
Recommended settings:
Build command: npm run build
Environment variables: RESEND_API_KEY, CONTACT_TO_EMAIL, CONTACT_FROM_EMAILThe contact API route is provided by Cloudflare Pages Functions, so it remains deployable on Cloudflare without exposing the Resend key in the browser.