Capri

Capri Shield · kit 0.4.0

Make your web app harder to copy.

Capri Shield makes your app harder to copy, replay and scrape, and tells you when copies appear. It can't make your app impossible to inspect: anything a browser shows or runs, a determined person can study. It stops a copy of your front end on another site from calling your server from its visitors' browsers, makes recorded requests expire, slows bursts of automated calls, and reports copies that keep your code. It doesn't hide your pages, text, design or page structure, it doesn't stop someone rebuilding your app by looking at it, it doesn't stop a copier who runs their own server in between (it only limits them), and it doesn't replace your own sign-in and permission checks.

What it does and doesn’t

Capri Shield makes your app harder to copy, replay and scrape, and tells you when copies appear. It can't make your app impossible to inspect: anything a browser shows or runs, a determined person can study. It stops a copy of your front end on another site from calling your server from its visitors' browsers, makes recorded requests expire, slows bursts of automated calls, and reports copies that keep your code. It doesn't hide your pages, text, design or page structure, it doesn't stop someone rebuilding your app by looking at it, it doesn't stop a copier who runs their own server in between (it only limits them), and it doesn't replace your own sign-in and permission checks.

On every page it wraps, the provider adds <meta name="capri-protection" content="no-copy">, an opt-out signal that copying tools can choose to honor, and <meta name="capri-site"> with your public site key, which lets Nika confirm that a reported page is a copy of yours.

Rate limits are best effort: each server instance keeps its own counts, so they catch bursts, not slow or spread-out scraping.

What it never does

  • It never slows or crashes a visitor’s device: the only work it asks of one is the quick security check, capped at 2 seconds.
  • It never blocks developer tools, right-click, copying or pasting.
  • It never shows crawlers or scanners different content, hides its code, or plants hidden instructions for anyone’s tools or AI agents. Its opt-out signal, a <meta name="capri-protection" content="no-copy"> tag on your pages and the optional Capri-Protection: no-copy header, states your wish in the open, like robots.txt, and binds only tools that choose to honor it.
  • It never fingerprints a device, gates on device attestation, or refuses anyone by browser, network or privacy relay alone.
  • It never blanks, redirects or breaks a page, even on a copy, and never retaliates against a copy’s host or its visitors.
  • It never treats a referrer, a hostname check or a key in your pages as sign-in: the secret stays on your server, and the site key is public by design.
  • No model runs anywhere in it.

What it doesn’t cover

  • Server Actions aren’t API calls, so Capri Shield doesn’t check them in any mode.
  • Calls your app makes straight to its database aren’t covered; your database’s own access rules protect them.
  • APIs outside /api/.
  • Apps served under a base path, and the Pages Router: not supported in this version.
  • A static export, which runs no middleware or route handlers.
  • A copier who runs their own server in between: only your limits apply to them.

Install in about 10 minutes

You need a Next.js 15 or 16 app with the App Router, TypeScript and its API under /api/, served by a Next.js server, not a static export. Counts, copy reports and the dashboard need an active Basic plan with your site added in the console; without one, see Without an account.

Start in the console’s Capri Shield card. The kit downloads from there, or from capri-shield-0.4.0.zip, once it’s open to you.

  1. Open https://www.codename-nika.com/capri/console/#shield, add your site with every address it’s served from (www. included), and copy the secret: it’s shown once.
  2. Download kit 0.4.0 from the same card, and unzip it outside your project folder.
  3. Copy its components/ and lib/ folders next to your app/ folder (inside src/ if your app/ is there), and merge its app/ folder into yours: it adds app/api/capri-shield/session/route.ts. The kit’s LICENSE travels in lib/capri-shield/. Leave README.md, capri-shield.json and examples/ out of your project.
  4. Add the settings the console shows, for production only, and to .env.local to try it locally: CAPRI_SHIELD_SECRET (the secret you copied), CAPRI_SHIELD_MODE, NEXT_PUBLIC_NIKA_CAPRI_SITE_KEY and NEXT_PUBLIC_NIKA_CAPRI_ORIGINS.
  5. Wrap your root layout’s children in <CapriProvider name="Your app"> (examples/layout.tsx).
  6. Add the server check next to your app/ folder: examples/middleware.ts on Next.js 15, or examples/proxy.ts on Next.js 16, with the options line the console shows. In the console, list your own /api route patterns under Your /api routes, like /api/orders/:id, so counts name them, and list under Routes left alone the /api routes your own server, other apps, emailed links or other sites call. Already have a middleware.ts or proxy.ts? Add the check to it (examples/compose.ts). On Next.js 16, a middleware.ts you already have counts: add the check there, never a second file.
  7. Deploy in Report only, then check it: curl -i -X POST https://your-site.example/api/capri-shield-check -H "Origin: https://another-site.example" (curl.exe on Windows). Nothing is refused yet, so your app answers as usual, likely 404, and within about 2 minutes the console’s last 7 days shows 1 call from other sites that would have been refused. That count proves the check, its secret, your site key and the counts work together. Then use your app for a while and read the last 7 days.
  8. Choose Standard in the console, set the CAPRI_SHIELD_MODE line it shows, and deploy again. The same call now answers 403 with Capri-Reason: cross_site. If either check fails, see the causes below.

If the call isn’t counted in Report only, or isn’t refused in Standard, check these in order:

  1. The deployed CAPRI_SHIELD_MODE is the value you meant: redeploy after changing it.
  2. CAPRI_SHIELD_SECRET and NEXT_PUBLIC_NIKA_CAPRI_SITE_KEY are set for this deployment’s environment.
  3. middleware.ts or proxy.ts sits next to your app/ folder (src/middleware.ts when app/ is in src/).
  4. Its matcher includes /api/:path*, and the address isn’t in exclude.
  5. A 308 answer means your app adds or drops trailing slashes: send the call to the address it redirects to.
  6. Only then, name the server settings with NIKA_ in front, like NIKA_CAPRI_SHIELD_SECRET and NIKA_CAPRI_SHIELD_MODE. The kit reads those ahead of the plain names, so from then on put NIKA_ in front of every CAPRI_SHIELD_ line the console gives you, and remove the plain ones.

Next.js 15: middleware.ts

On Next.js 15 the check is middleware.ts, next to your app/ folder, or src/middleware.ts beside src/app. The options line the console shows replaces the options in its capriShield(…) call; keep any signIn or limits you add yourself.

middleware.ts, from examples/middleware.ts
// middleware.ts for Next.js 15, next to your app/ folder (src/middleware.ts when app/ is in src/).
import { capriShield } from './lib/capri-shield/middleware'

// The console's options line replaces the options in this call. Keep any signIn or limits you add yourself.
// exclude: Routes left alone, as the console lists them: /api routes other sites, apps, scheduled jobs or emailed links
//   call, like signed webhooks. They pass straight through.
// routes: Your /api route patterns, as the console lists them, so refusal counts name the route.
// forms: Strict's form routes: the exact /api paths your pages post forms to, link to or load. In Strict, their GET,
//   HEAD and POST requests keep Standard's checks.
// signIn: your sign-in routes, which get a tighter limit per session. Without it: ['/api/auth/signin', '/api/auth/signup'].
export default capriShield({ exclude: ['/api/webhooks/:path*'], routes: [], forms: [] })

export const config = { matcher: ['/api/:path*'] }

Next.js 15.5.28 or later is the newest security release on our list, checked 2026-10-14; 15.2.3 at the very least, since it fixed a way to skip middleware.

Next.js 16: proxy.ts

On Next.js 16 the same check is proxy.ts, next to your app/ folder, or src/proxy.ts beside src/app.

proxy.ts, from examples/proxy.ts
// proxy.ts for Next.js 16, next to your app/ folder (src/proxy.ts when app/ is in src/). Not yet run on a Next.js 16 app.
import { capriShield } from './lib/capri-shield/middleware'

// The console's options line replaces the options in this call. Keep any signIn or limits you add yourself.
// exclude: Routes left alone, as the console lists them: /api routes other sites, apps, scheduled jobs or emailed links
//   call, like signed webhooks. They pass straight through.
// routes: Your /api route patterns, as the console lists them, so refusal counts name the route.
// forms: Strict's form routes: the exact /api paths your pages post forms to, link to or load. In Strict, their GET,
//   HEAD and POST requests keep Standard's checks.
// signIn: your sign-in routes, which get a tighter limit per session. Without it: ['/api/auth/signin', '/api/auth/signup'].
export default capriShield({ exclude: ['/api/webhooks/:path*'], routes: [], forms: [] })

export const config = { matcher: ['/api/:path*'] }

Next.js 16 runs this file as proxy.ts. These steps follow Next.js 16’s documentation and haven’t been run on a Next.js 16 app yet.

Already have middleware.ts or proxy.ts

Add the check to the one you have: it runs first for calls to /api/, and your own code runs everywhere else.

Your middleware.ts or proxy.ts, from examples/compose.ts
// middleware.ts (Next.js 15) or proxy.ts (Next.js 16) that already exists: keep yours, and put the check first for /api/.
import { NextResponse, type NextFetchEvent, type NextRequest } from 'next/server'
import { capriShield } from './lib/capri-shield/middleware'

const shield = capriShield({ exclude: ['/api/webhooks/:path*'], routes: [], forms: [] })

// Your existing middleware: your own function as it is, or the helper you export today, like const yours = someHelper({ … }).
async function yours(request: NextRequest, event: NextFetchEvent) {
  // ...your own code, as before
  return NextResponse.next()
}

// On Next.js 16, name this function proxy, or keep it as the default export.
export default async function middleware(request: NextRequest, event: NextFetchEvent) {
  if (request.nextUrl.pathname.startsWith('/api/')) {
    const refused = await shield(request, event)
    if (refused) return refused
    // Did your matcher already cover /api/? Then return yours(request, event) here instead.
    return NextResponse.next()
  }
  return yours(request, event)
}

// Keep your own entries, and add '/api/:path*' if they skip /api.
export const config = { matcher: ['/api/:path*'] }
  • Keep yours, and put the check first for calls to /api/. Its matcher must let calls to /api/ through: add /api/:path* as its own entry if yours skips /api.
  • If your own middleware signs visitors in or protects routes, keep /api/capri-shield/session open to everyone: the provider calls it on every visit.
  • On Next.js 16, a middleware.ts you already have counts: add the check there, never a second file.

Adding the check to an existing proxy.ts on Next.js 16 hasn’t been run yet.

The provider

Wrap your root layout’s children in <CapriProvider name="Your app">, with your app’s name as the copy notice shows it, and keep your own <html>, <body>, fonts and other providers.

app/layout.tsx, from examples/layout.tsx
// app/layout.tsx (src/app/layout.tsx when app/ is in src/): your root layout, with its children wrapped.
// Keep your own <html>, <body>, fonts and other providers, and add the wrapper around children. The provider reads
// NEXT_PUBLIC_NIKA_CAPRI_SITE_KEY and NEXT_PUBLIC_NIKA_CAPRI_ORIGINS when your app is built.
import type { ReactNode } from 'react'
import { CapriProvider } from '../components/CapriProvider'

export default function RootLayout({ children }: { children: ReactNode }) {
  return (
    <html lang="en">
      <body>
        <CapriProvider name="Your app">{children}</CapriProvider>
      </body>
    </html>
  )
}

You can pass siteKey and origins as props, but keep NEXT_PUBLIC_NIKA_CAPRI_SITE_KEY and NEXT_PUBLIC_NIKA_CAPRI_ORIGINS set as well: your server reads them to send refusal counts and to accept your other addresses.

Without a site key or enabled, it renders your page and makes no requests, so in Standard your pages’ API calls are refused for lack of a session. Set the site key before the build.

Route handlers

A route handler like app/api/orders/route.ts, from examples/route.ts
// app/api/orders/route.ts (under src/ when app/ is in src/): one of your route handlers, checked again.
// withCapri runs the same-site and session checks where the work happens (and the proof, in Strict), then your handler,
// so a call that gets past the middleware is still checked. It never replaces your own sign-in and your own rules about
// who may do what: they stay the real gate. In Strict, leave a form route (one in the forms list) unwrapped: a form post
// can't carry a proof.
import { withCapri } from '../../../lib/capri-shield/server'

export const POST = withCapri(async (request: Request) => {
  // ...your own sign-in check and your own rules about who may do what, as before
  const order = await request.json()
  return Response.json({ received: typeof order === 'object' && order !== null })
})

examples/route.ts wraps a route handler in withCapri() from lib/capri-shield/server.ts. It runs the same-site and session checks again where the work happens (and the proof, in Strict), then your handler, so a call that gets past the middleware is still checked. It never replaces your own sign-in and your own rules about who may do what. In Strict, leave a form route unwrapped.

Headers (optional)

next.config.mjs, from examples/next.config.mjs
// next.config.mjs (optional), at your project's root: two headers on every page, only where a mode is set when the app
// is built, so a preview without one can still be framed. Already have a config? Add this headers() rule to yours.
// Skip it if other sites are meant to frame your app.
const nextConfig = {
  async headers() {
    if (!process.env.CAPRI_SHIELD_MODE && !process.env.NIKA_CAPRI_SHIELD_MODE) return []
    return [
      {
        source: '/:path*',
        headers: [
          // Other sites can't show your pages in a frame.
          { key: 'Content-Security-Policy', value: "frame-ancestors 'self'" },
          // The opt-out signal, stated in the open like robots.txt, for copying tools that choose to honor it.
          { key: 'Capri-Protection', value: 'no-copy' },
        ],
      },
    ]
  },
}

export default nextConfig

examples/next.config.mjs adds two headers to every page wherever CAPRI_SHIELD_MODE is set when your app is built: Content-Security-Policy: frame-ancestors 'self', so other sites can’t show your pages in a frame, and Capri-Protection: no-copy, the opt-out signal. Already have a next.config? Add its headers() rule to yours. Skip it if other sites are meant to frame your app.

Settings

SettingWhere it goesValueWhat it does
CAPRI_SHIELD_SECRETServer onlyThe secret shown once (32 characters or more)Signs sessions and refusal counts. Without it, or under 32 characters, nothing is checked.
CAPRI_SHIELD_MODEServer onlycapri-mode-report, capri-mode-enforce or capri-mode-boundReport only, Standard or Strict. Without it, Report only.
NEXT_PUBLIC_NIKA_CAPRI_SITE_KEYBuilt into your pages, and read by your serverYour public site key, nika_cp_pk_…Turns the provider on in your pages, and names your site in copy reports and refusal counts.
NEXT_PUBLIC_NIKA_CAPRI_ORIGINSBuilt into your pages, and read by your serverYour site’s addresses, comma-separated, www. includedPages on these addresses may call your API, and are never reported as copies.
CAPRI_SHIELD_STRICTServer only, optionalcapri-strict-checkChecks Strict first: counts what Strict would refuse, and refuses nothing more.
CAPRI_SHIELD_STEPServer only, optionalLike capri-step-on;signin=/api/auth/signinThe quick security check, on the routes it names.
CAPRI_SHIELD_STATSServer only, optionalcapri-stats-offStops sending refusal counts to Nika.
CAPRI_SHIELD_TTLServer only, optionalcapri-ttl-<seconds>, 300 to 43200A shorter session, for testing.

Set the settings for production only. The provider knows your production build’s own addresses only on a hosting platform that sets them at build time, so a preview with a site key may report itself as a copy.

You can pass siteKey and origins as props, but keep NEXT_PUBLIC_NIKA_CAPRI_SITE_KEY and NEXT_PUBLIC_NIKA_CAPRI_ORIGINS set as well: your server reads them to send refusal counts and to accept your other addresses.

examples/env.example holds these lines for .env.local, with the optional ones commented out.

.env.local, from examples/env.example
# Capri Shield's settings, for .env.local to try it locally. Deployed, set them in your server's environment for
# production only. The console shows your own values.
# CAPRI_SHIELD_SECRET: add the secret shown when you added this site or rotated it; it isn’t shown again
CAPRI_SHIELD_MODE=capri-mode-report
NEXT_PUBLIC_NIKA_CAPRI_SITE_KEY=
NEXT_PUBLIC_NIKA_CAPRI_ORIGINS=https://your-site.example
# Optional:
# CAPRI_SHIELD_STRICT=capri-strict-check
# CAPRI_SHIELD_STEP=capri-step-on;signin=/api/auth/signin
# CAPRI_SHIELD_STATS=capri-stats-off
# CAPRI_SHIELD_TTL=capri-ttl-300

Modes

ModeCAPRI_SHIELD_MODEWhat it does
Report onlycapri-mode-reportChecks every API call and refuses nothing; it counts what it would refuse.
Standardcapri-mode-enforceRefuses calls from other sites, missing or expired sessions, and over-limit bursts.
Strictcapri-mode-boundAlso needs a fresh proof on every API call your pages make, signed by a key the visitor’s browser keeps for the session and can’t export, so a recorded call stops working 30 seconds after it was made. GET, HEAD and POST requests to the form routes your pages use keep Standard’s checks, fetch calls included.

Start in Report only, read the last 7 days, leave alone or fix what it lists, then switch to Standard.

Strict and its form routes

A browser can’t add a proof to a form post, a link or a page load. List the exact /api paths your pages post forms to, link to or load in the forms option (the console keeps them as Strict’s form routes, and its options line carries them): in Strict, their GET, HEAD and POST requests keep Standard’s checks, and other methods there still need a proof. A :name part covers every route it matches, as /api/:slug covers /api/orders, so list exact paths where you can.

Strict’s form routes in the console: One route per line, like /api/auth/signin. Use :name for one part of the path; a form route can’t end in :name* or :name+.

Leave those routes unwrapped by withCapri: in Strict it checks a proof there, which a form post can’t carry.

Strict can’t sign these, so it refuses them:

  • calls made with XMLHttpRequest, or a library built on it
  • calls from a web worker
  • calls a service worker makes to your API by itself
  • fetch calls with mode: no-cors, which drop the proof
  • calls made while patchFetch={false} is set, unless they go through useCapriFetch()
  • calls made before the provider’s fetch helper is ready: during render, in a layout effect or at load
  • a very slow upload that takes longer than a proof lasts (30 seconds)
  • a streamed request body: it’s signed, but not sent again after a refusal

Before you switch, run Check Strict first (CAPRI_SHIELD_STRICT=capri-strict-check) and read Refusals by route in the console, with your routes listed.

Very old browsers that can’t keep a signing key can’t use your app’s API in Strict. Server Actions aren’t API calls, so Capri Shield doesn’t check them in any mode.

Check Strict first

Set CAPRI_SHIELD_STRICT=capri-strict-check on your server in Report only or Standard, and redeploy: the console gives you the line, and shows what it counts under Refusals by route.

Browsers sign their API calls as they would in Strict, and nothing more is refused. Once you redeploy with it, calls that come without a proof, or with one too old for Strict, are counted below by route: Strict would refuse those. They may come from your own pages (form posts, links, or code that calls your API another way than fetch) or from a script reusing a session, so check which before you change anything. Pages opened before you redeployed are counted too, until they reload.

While it’s on, visitors’ browsers keep a signing key for each session, as in Strict: the paragraph under Privacy says so, so update your privacy policy if you copied an earlier version of it.

The quick security check

On the API routes you choose, the visitor’s browser does a short calculation before the call goes through: usually well under a second, and never more than two seconds. If it takes more than a moment, a line on the page says “Running a quick security check…”. A script that skips the check waits about a second a call; one that runs the check itself loses only a moment, so it deters abuse at scale, not one determined person. It’s best effort: each server instance remembers answers on its own. There’s never a puzzle, and nobody is turned away: a call that can’t run the check, or doesn’t finish it in two seconds, waits one second instead and then goes through.

Pages are never checked, only the API routes you choose. It changes when you redeploy with the new setting.

It’s one setting on your server, like CAPRI_SHIELD_STEP=capri-step-on;burst;signin=/api/auth/signin;checkout=/api/checkout. Set it in the console, which gives you the line. It starts with one of these:

  • capri-step-on: On.
  • capri-step-count: Count only. Counts what it would ask for, without asking anyone or making anyone wait.
  • capri-step-off: Off.

Then come parts split by semicolons: burst also asks for the check when many new sessions come from one address, and each kind=route,route part lists your own /api route patterns for one kind of route:

  • signup: Sign-up
  • signin: Sign-in
  • checkout: Checkout
  • export: Exports and downloads
  • ai: AI features

When a call is refused

A refused call gets the status below, a Capri-Reason header with the reason, and a short JSON message. In Report only nothing is refused: the same calls are counted instead.

ReasonStatusUsual causeFix
cross_site403A call from another site, or from a link or callback that starts on another site.List every address your pages are served from in NEXT_PUBLIC_NIKA_CAPRI_ORIGINS. Add the routes other sites send people to, like sign-in callbacks and emailed links, to Routes left alone.
no_session401A call with no live session: from your own server, a phone app, a scheduled job or another client, or from your pages when the provider isn’t running.From your pages: set NEXT_PUBLIC_NIKA_CAPRI_SITE_KEY before the build, rebuild, and wrap the root layout in <CapriProvider>. From your own server code: call your function directly, not your own /api address. For other apps and jobs: add the route to Routes left alone.
stale_session401A session that expired, or one signed with a secret you rotated since.The provider renews it and sends the call again by itself. After Rotate secret, redeploy with the new one.
bad_proof401Strict only: a call without a fresh proof.Check your form routes and the calls Strict can’t sign (under Strict). Check Strict first counts these before you switch.
rate_slow429One session went over a limit: 120 calls a minute to one group of routes, or 10 sign-in attempts in 10 minutes.It answers with Retry-After and clears by itself. If real people hit it, raise the limit in capriShield({ limits }).
rate_block429The same session went over a limit again within 10 minutes.It clears after 10 minutes. Report only shows which routes would get these before you switch.

Your server’s log shows each refusal as [capri-shield] refused: <reason> <method> <path>, and in Report only as would refuse (report mode). It never logs a query, an address or a session.

Copies and notices

A copy of your pages that keeps the provider and your site key reports itself: on an address your origins don’t list, each visitor’s browser tells Nika once per session (what it sends is under Privacy). Nika then looks at the reported page once a day for your site key, and lists the address with your copies once it’s found there.

  • This is mine: the address is yours, so it joins your site’s addresses. Add it to NEXT_PUBLIC_NIKA_CAPRI_ORIGINS too, and rebuild.
  • Show notice there: a line at the bottom of that copy’s pages tells its visitors it’s an unofficial copy and names your site, and they can dismiss it. It shows only on a copy Nika verified and you chose, and never blanks or redirects a page.
  • Dismiss: the address leaves your list of copies.

Check a URL asks Nika to look at one page you name, and lists it with your copies if your site key is there.

Copy reports from visitors’ browsers start for sites built outside Nika once our privacy documents cover them. Until then Nika stores none of them, and no notice shows on a copy. A page you check yourself with Check a URL is still checked, and listed if it’s a copy.

Privacy

What reaches Nika

  • From a copy of your site on another address, each visitor’s browser sends Nika two requests once per browser session: one report (that address, the page’s path without its query, and the time) and one question about whether to show the copy notice. No cookies, no referrer.
  • Each reaches Nika from the visitor’s IP address. Nika keeps it only as a hash in an expiring rate-limit counter, never with a report; the request logs of Nika’s hosting follow their own retention.
  • While copy reports are off for your site, both still arrive, but Nika keeps no report and shows no notice.
  • From your servers, in production only, at most once a minute from each server instance: refusal counts by day, route pattern and reason, signed with your secret, with no address, session, cookie, query or header. CAPRI_SHIELD_STATS=capri-stats-off stops them.
  • From your own site’s visitors’ browsers: nothing, as long as your origins list every address it’s served from.

What Nika keeps

  • Copy reports: one row per address a copy was seen on (the address, one sample path, a count, and the first and last time), kept while your site is registered. One Nika never verified stops showing after 30 days without a new report.
  • A copy Nika verified also keeps its evidence: the address checked, when, and a hash of that page.
  • Refusal counts: 90 days.
  • When you remove a site, its counts and reports are deleted 30 days later. Nika keeps only the site’s key and whose it was, so the key is never reused.
  • If your Basic plan ends, nothing is deleted: what Nika has follows these rules until you remove the site.

What the kit keeps

  • On a visitor’s device: the security cookie (a random session id, 12 hours at most); in each tab’s session storage, when that session ends, the clock offset and which checks it uses, and, on a copy of your site, whether this tab already reported it and the notice answer; in Strict, or while Strict is checked first, a signing key kept in the browser and replaced with each session.
  • On your server, in memory only: counts by session and by a hash of the visitor’s address, for an hour at most, never written to storage.

For your privacy policy

A paragraph you can use:

We use a security cookie to protect our service from automated copying and abuse. It contains a random session id, expires within 12 hours, and is not used for analytics or advertising. When this site uses its strictest checks, or is testing them, your browser also keeps a private signing key for that session, which never leaves your device and is replaced with each new session.

These are the facts of what the kit sends and keeps; whether your users’ laws need anything more is yours to check.

Price and limits

Basic, $50 a month

Capri Shield on up to 10 of your sites, using none of your Capri credits.

  • Up to 10 sites at a time, and up to 20 new sites in 24 hours, removed ones included.
  • Sites are managed in the console: there’s no API for them yet.

When Basic ends (a canceled plan, an unpaid renewal after its 3 days of grace, a refund, or Capri access paused on your account), Nika pauses what it hosts for your sites: refusal counts and copy reports within about 5 minutes, and notices within about 10 minutes for new visits. Your app’s own checks keep running. You can still rotate a secret, remove a site or switch it to Report only, and counting resumes within about an hour and 5 minutes once Basic is back.

Without an account

  • The kit works without a Capri account, with its in-app checks only: sessions, the same-site check, the limits and Strict. There are no counts, copy reports or dashboard.
  • Wrap your layout in <CapriProvider enabled name="Your app">, with no site key.
  • Set CAPRI_SHIELD_SECRET to a random string of 32 characters or more, made for example with node -e "console.log(require('crypto').randomBytes(32).toString('base64url'))", and CAPRI_SHIELD_MODE as above.
  • Add the middleware and the session route as in steps 3 and 6.

Files and integrity

capri-shield.json holds the version, each kit file’s hash, and the hashes of earlier versions.

Filesha256
app/api/capri-shield/session/route.ts65fae03194f3c4148714b9af4d64e34dd29776ba66f65683a74c296efbea567d
components/CapriCheck.ts87bacf5b852b86a15d980f94aab2d7dfc1968da6b2347a112ca9f89bf69ff92d
components/CapriNotice.tsxd7c93a27dcc2dd34d6fff223ba0d86317860c350983b3b3f512384cd0223c655
components/CapriProvider.tsx96eeba8651c48a2a1a079d51d7bb6b3faa2709c356a49a6afcbd8d54d1178ca8
lib/capri-shield/core.tsad68933445abd3c54818fe115752cabee86e1ba586c3c33445c1d610be3d357f
lib/capri-shield/headers.tsa97230cbfcf6a8b39a6986316ffeb5988f006087ef446d677c92c9e8277a1140
lib/capri-shield/middleware.ts1cbe153041708a923ef36f0173952d0b835b7e2e9fae255752d16205ecb7e6d4
lib/capri-shield/server.ts675544a445f5e2a0aed87c583ec54dfe199cff97e19eef8091a857b5e29b6bb3
lib/capri-shield/session-route.tsca61f5d2d7f513227b3885b16b32531aea2eabf9585a5baefa61282ec04150eb
lib/capri-shield/step.ts7736c28e9c08b4b15cdaf28c48052910163c6eb996597dae1b2f7849903e4519

Each hash is the sha256 (hex) of each file’s text as UTF-8, with LF line endings, no spaces or tabs at line ends and one final newline.

To check your copies with Node.js, run this inside the unzipped folder:

Inside the unzipped folder
node -e "var fs=require('fs'),path=require('path'),crypto=require('crypto');var file=process.argv[1],base=process.argv[2]||'',list=JSON.parse(fs.readFileSync(file,'utf8')).files;Object.keys(list).forEach(function(f){var p=path.posix.join(base,f),t=null;try{t=fs.readFileSync(p,'utf8')}catch(e){}if(t===null){console.log('MISSING '+p);return}t=t.replace(/\r\n/g,'\n').replace(/[ \t]+$/gm,'').replace(/\n*$/,'\n');console.log((crypto.createHash('sha256').update(t,'utf8').digest('hex')===list[f]?'ok':'DIFF')+' '+p)})" capri-shield.json

Or from your project, with the path to that folder’s capri-shield.json (leave out src/ when your app/ folder is at the root):

From your project
node -e "var fs=require('fs'),path=require('path'),crypto=require('crypto');var file=process.argv[1],base=process.argv[2]||'',list=JSON.parse(fs.readFileSync(file,'utf8')).files;Object.keys(list).forEach(function(f){var p=path.posix.join(base,f),t=null;try{t=fs.readFileSync(p,'utf8')}catch(e){}if(t===null){console.log('MISSING '+p);return}t=t.replace(/\r\n/g,'\n').replace(/[ \t]+$/gm,'').replace(/\n*$/,'\n');console.log((crypto.createHash('sha256').update(t,'utf8').digest('hex')===list[f]?'ok':'DIFF')+' '+p)})" path/to/capri-shield.json src/

Each line says ok, DIFF (the file changed) or MISSING, then the file’s path.

The download’s own sha256 is in its Capri-Kit-Sha256 header.

LICENSE holds the MIT license, and lib/capri-shield/LICENSE holds it again, so it travels with the files you copy.

The examples aren’t hashed: each is a starting point for one file in your project, under src/ when your app/ folder is there (next.config.mjs and .env.local stay at the root).

Updating and removing

Replace lib/capri-shield/ and the three components/Capri* files with a newer download; the layout, middleware or proxy, and settings stay. To remove it, take out the wrapper and the check lines, delete the copied files (app/api/capri-shield/ too), remove the settings, then remove the site in the console.

Versions

VersionWhat it brought
0.4.0Strict’s form routes, Check Strict first, the quick security check, and the copy notice loading only where it shows
0.3.0Refusal counts
0.2.0The copy notice and its check
Capri Shield docs · make the web apps you build harder to copy