A production-ready Next.js 15 boilerplate with 7 security headers, CI/CD vulnerability scanning, and hardened defaults β all pre-configured so you can ship secure apps from day one.
| Header | Value | Protection |
|---|---|---|
X-Content-Type-Options |
nosniff |
Prevents MIME-type sniffing |
X-Frame-Options |
DENY |
Blocks clickjacking via iframes |
Strict-Transport-Security |
max-age=63072000; includeSubDomains; preload |
Enforces HTTPS for 2 years |
Referrer-Policy |
strict-origin-when-cross-origin |
Controls referrer data leakage |
Permissions-Policy |
geolocation=(), microphone=(), camera=() |
Restricts browser API access |
X-XSS-Protection |
1; mode=block |
Enables browser XSS filtering |
X-Permitted-Cross-Domain-Policies |
none |
Blocks Flash/PDF cross-domain access |
Additionally, X-Powered-By is removed (poweredByHeader: false) to prevent server fingerprinting.
A GitHub Actions workflow (.github/workflows/security.yml) runs automatically on every pull request:
- Secret Detection β Catches API keys, tokens, and credentials before they're merged.
- PII Scanning β Detects personally identifiable information in your codebase.
- Dependency Auditing β Flags known vulnerabilities in your npm packages.
Powered by Precogs AI.
- Next.js 15 with App Router
- TypeScript (strict mode)
- Tailwind CSS v4
- React Compiler enabled
- ESLint pre-configured
# Clone
npx create-next-app@latest -e https://github.com/PrecogsAI/secure-nextjs-starter my-app
# Or clone directly
git clone https://github.com/PrecogsAI/secure-nextjs-starter.git
cd secure-nextjs-starter
npm install
npm run devOpen http://localhost:3000.
After deploying, scan your site at securityheaders.com to confirm all headers are active.
βββ .github/
β βββ workflows/
β βββ security.yml # Precogs AI security scan on PRs
βββ src/
β βββ app/
β βββ layout.tsx # Root layout with SEO metadata
β βββ page.tsx # Landing page
β βββ globals.css # Global styles
βββ next.config.ts # Security headers configuration
βββ package.json
βββ tsconfig.json
CSP is not included by default because it varies per project. To add it, extend the securityHeaders array in next.config.ts:
{
key: "Content-Security-Policy",
value: "default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:;",
}The included workflow uses the free tier. To enable deep code analysis, update .github/workflows/security.yml:
- uses: PrecogsAI/precogs-action@v1
with:
scan_type: pro
api_key: ${{ secrets.PRECOGS_API_KEY }}MIT β use this starter for anything.
Security powered by Precogs AI