Run the development server:
cp .env.example .env.local
cp .dev.vars.example .dev.vars
pnpm devOpen http://localhost:3000 with your browser to see the result.
The contact form uses:
- a Next.js Route Handler at
/api/contact - Cloudflare Turnstile for bot protection
- Resend for email delivery from
contact@portfolio.nigb.dev
Required local files:
.env.localNEXT_PUBLIC_TURNSTILE_SITE_KEY
.dev.varsCONTACT_FROM_EMAILRESEND_API_KEYTURNSTILE_SECRET_KEY
Cloudflare and Resend setup:
- Create a Turnstile widget for
portfolio.nigb.dev. - Add
localhostand127.0.0.1to the Turnstile widget for local development. - Copy the Turnstile site key into
.env.localand your deployment build environment. - Copy the Turnstile secret key into
.dev.varsfor local development and into a Worker secret for deployed environments. - In Resend, add and verify the sending domain used by
contact@portfolio.nigb.dev. - Create a Resend API key with permission to send emails.
- Store the API key as
RESEND_API_KEYin.dev.varsand as a Worker secret in deployed environments.
Notes:
- The Turnstile site key is public and safe to expose to the client.
- The Turnstile secret key must stay server-only.
- Resend will reject mail if
CONTACT_FROM_EMAILis not part of a verified sender domain.
This project deploys to Cloudflare Workers at https://portfolio.nigb.dev.
Manual deploy:
pnpm run deployBefore deploying the contact form, make sure:
NEXT_PUBLIC_TURNSTILE_SITE_KEYis available during the Next.js build in your local shell or CI environment.CONTACT_FROM_EMAIL,RESEND_API_KEY, andTURNSTILE_SECRET_KEYare stored as Worker secrets.
The workflow in .github/workflows/deploy.yml deploys automatically on every push to main.
Before it can work in GitHub Actions, add these repository secrets:
CLOUDFLARE_ACCOUNT_ID: your Cloudflare account IDCLOUDFLARE_API_TOKEN: API token with permission to deploy Workers and manage the target zoneNEXT_PUBLIC_TURNSTILE_SITE_KEY: the public Turnstile site key used by the client bundleRESEND_API_KEY: the API key used to send contact emails
After adding the secrets, push to main or run the workflow manually from the Actions tab.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!