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
styleprops, so your policy should allowstyle-src-attr 'unsafe-inline'. - Style elements take a nonce:
TextReveal,ScrollReveal,Marquee,StickyScrollStoryand both compositions accept anoncefor 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:
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:
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.