Skip to content

Latest commit

 

History

History
67 lines (50 loc) · 1.69 KB

README.md

File metadata and controls

67 lines (50 loc) · 1.69 KB
Arcjet Logo

@nosecone/next

npm badge

Protect your Next.js application with secure headers.

Installation

npm install -S @nosecone/next

Example

Create a middleware.ts file with the contents:

import { createMiddleware } from "@nosecone/next";

export const config = {
  // matcher tells Next.js to run middleware on all routes
  matcher: ["/(.*)"],
};

export default createMiddleware();

Add await connection() in your app/layout.tsx file:

+ import { connection } from "next/server";

export default async function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
+  // Opt-out of static generation for every page so the CSP nonce can be applied
+  await connection()

  return (
    <html lang="en">
      <body className={inter.className}>{children}</body>
    </html>
  );
}

License

Licensed under the Apache License, Version 2.0.