Skip to content

Security

Works under a strict CSP

The components and the runtime need no 'unsafe-eval' and no inline script without a hash or a nonce.

What the components need

  • No eval: shaders compile through the GPU driver (gl.compileShader): no 'unsafe-eval', no WebAssembly code generation.
  • Inline style attributes: positions, sizes and token variables are set through React style props, so your policy should allow style-src-attr 'unsafe-inline'.
  • Style elements take a nonce: TextReveal, ScrollReveal, Marquee, StickyScrollStory and both compositions accept a nonce for the <style> they render.

A script hash for Next.js

Without per-request nonces, use the exact SHA-256 of the inline MotionReadyScript, which the runtime exports:

CSP
import { MOTION_READY_SCRIPT_HASH } from "@frictionborn/runtime";
// in your CSP header:
// script-src 'self' '${MOTION_READY_SCRIPT_HASH}' 'strict-dynamic';

Nonces in Next.js 16

Generate a nonce in proxy.ts (the Next.js 16 convention) and pass it down from the root layout:

app/layout.tsx
import { headers } from "next/headers";
import { MotionReadyScript } from "@frictionborn/runtime";

export default async function RootLayout({ children }: { children: React.ReactNode }) {
  const nonce = (await headers()).get("x-nonce") ?? undefined;
  return (
    <html lang="en">
      <head>
        <MotionReadyScript nonce={nonce} />
      </head>
      <body>{children}</body>
    </html>
  );
}

What next

The getting started guide shows where MotionReadyScript goes; conventions lists the nonce prop with the others.