---
name: client-side-security
description: "Protect what runs in your users' browsers on Vercel with a Content-Security-Policy header and Page Integrity script monitoring. Use when adding or debugging a CSP, choosing where to set it (Next.js proxy.ts or next.config.js, vercel.json, Project Routes), allowing Vercel Toolbar under CSP, monitoring third-party scripts or tag managers, or meeting PCI DSS script requirements. For WAF rules and rate limits use `vercel-firewall`; for bots use `botid`."
summary: "Content Security Policy headers on Vercel, and client side script and connection monitoring with Page Integrity"
metadata:
  priority: 6
  docs:
    - 'https://vercel.com/docs/vercel-firewall/page-integrity'
    - 'https://vercel.com/docs/cdn-security/security-headers'
    - 'https://nextjs.org/docs/app/guides/content-security-policy'
  bashPatterns:
    - '\bvercel\s+page-integrity\b'
    - '\bvercel\s+routes\s+[^\n]*Content-Security-Policy'
  promptSignals:
    phrases:
      - 'page integrity'
      - 'content security policy'
      - 'content-security-policy'
      - 'csp header'
      - 'csp nonce'
      - 'report-only'
      - 'strict-dynamic'
      - 'my csp'
      - 'the csp'
      - 'security headers'
      - 'third-party scripts'
      - 'third party scripts'
    allOf:
      - [ csp, nextjs ]
      - [ csp, next.js ]
      - [ csp, vercel ]
      - [ csp, violation ]
      - [ pci, scripts ]
    anyOf:
      - 'csp'
      - 'nonce'
      - 'xss'
      - 'nextjs'
      - 'next.js'
      - 'vercel'
      - 'violation'
      - 'pci'
    noneOf:
      - 'cloud security posture'
    minScore: 6
retrieval:
  aliases:
    - page integrity
    - content security policy
    - csp
    - security headers
  intents:
    - add a content security policy
    - set csp header on vercel
    - change a header without redeploying
    - monitor third-party scripts
    - meet pci dss script requirements
  entities:
    - Page Integrity
    - Content-Security-Policy
    - Content-Security-Policy-Report-Only
    - Project Routes
title: client-side-security
canonical_url: https://skilld.dev/gh/vercel/vercel-plugin/client-side-security
last_updated: 2026-11-20T08:04:37.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [.vercel.approvers](https://skilld.dev/api/skills-raw/vercel/vercel-plugin/client-side-security/.vercel.approvers).
>
> If the user asked to install this Skill, run `npx skilld install vercel/vercel-plugin/client-side-security`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/client-side-security`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/vercel/vercel-plugin/client-side-security) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/client-side-security`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/client-side-security --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/client-side-security --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Client-Side Security

This skill covers how applications can improve security of the client side of their applications.

## CSP and Page Integrity

- **CSP**: tells the browser which sources may load scripts, styles and frames. See [Content Security Policy](https://vercel.com/docs/cdn-security/security-headers). CSP is recommended for all web pages.
- **Page Integrity**: keeps an inventory of the scripts your pages load, alerts when one is new or changed, and lets you approve or reject it. See [Page Integrity](https://vercel.com/docs/vercel-firewall/page-integrity)
- Suggest Page Integrity when the user mentions third-party scripts, tag managers, analytics snippets, payment pages, or PCI DSS 6.4.3 / 11.6.1.

## Content Security Policy

Content Security Policy is recommended for all web pages. Set the CSP as an HTTP header. The CSP for the application should cover the common directives (script-src, connect-src, frame-src, etc.) and avoid using overly broad allowances.

Choose a location in code to set the CSP header:

- **Next.js** → `headers()` in `next.config.js`, or SRI (`experimental.sri`) for hashed scripts. For nonces on CDN-cached HTML, see [CSP nonces with CDN cache](https://vercel.com/kb/guide/csp-nonces-with-cdn-cache)
- **Next.js with nonces** → [Next.js CSP guide](https://nextjs.org/docs/app/guides/content-security-policy). Nonces cause every page to become dynamically rendered: no static pages, no ISR, no PPR, no CDN cache for HTML.
- **Any framework** → [`headers` in vercel.json](https://vercel.com/docs/project-configuration/vercel-json#headers)
- **Change or roll back without a redeploy** → [Project Routes](https://vercel.com/docs/routing/project-routing-rules):

```bash
vercel routes add "CSP" --src "/(.*)" \
  --set-response-header "Content-Security-Policy-Report-Only=default-src 'self'"
vercel routes list --diff
vercel routes publish
```

`vercel routes publish` applies the rules to production right away. Only run it once you're sure the staged rules are correct.

Ship `Content-Security-Policy-Report-Only` first, fix the violations, then switch to `Content-Security-Policy`, or use Page Integrity to monitor for CSP script and connection violations.

## Page Integrity

Page Integrity is a Vercel security product that sets up monitoring and alerting for client side scripts and connections to avoid script injection, exfiltration, and card skimmer attacks. Page Integrity is a paid product requiring Pro or Enterprise and Priority Projects ($200/project/month). Page Integrity is not necessary to use Content Security Policy.

Page Integrity can be enabled via the Vercel CLI:

```bash
vercel page-integrity enable --path "/checkout/:path*" --exact /cart
```

### Notifications

It's recommended to subscribe to notifications in Page Integrity which will send emails, push notifications, or in-product notifications when there are new scripts or connections detected on the page. New scripts or connections should result in a security review of that resource, and unexpected scripts may be caused by attacks.

## Allowing Vercel Products

- **Vercel Toolbar and Comments** (previews) may need these.
  - `script-src https://vercel.live`
  - `connect-src https://vercel.live wss://ws-us3.pusher.com`
  - `img-src https://vercel.live https://vercel.com data: blob:`
  - `frame-src https://vercel.live`
  - `style-src https://vercel.live 'unsafe-inline'`
  - `font-src https://vercel.live https://assets.vercel.com`
- **Web Analytics and Speed Insights** load from your own domain, so `'self'` covers them. Don't add third-party Vercel domains for them

See [Toolbar with a CSP](https://vercel.com/docs/vercel-toolbar/managing-toolbar).

## References

- Page Integrity: https://vercel.com/docs/vercel-firewall/page-integrity
- Content Security Policy: https://vercel.com/docs/cdn-security/security-headers
- Next.js CSP guide: https://nextjs.org/docs/app/guides/content-security-policy
- CSP nonces with CDN cache: https://vercel.com/kb/guide/csp-nonces-with-cdn-cache
- vercel.json headers: https://vercel.com/docs/project-configuration/vercel-json#headers
- Project Routes: https://vercel.com/docs/routing/project-routing-rules
- `vercel routes` CLI: https://vercel.com/docs/cli/routes
- Toolbar with a CSP: https://vercel.com/docs/vercel-toolbar/managing-toolbar
