diff --git a/src/commands/add/auth/clerk/generators.ts b/src/commands/add/auth/clerk/generators.ts
index 4fb12e24..fb3fe7bd 100644
--- a/src/commands/add/auth/clerk/generators.ts
+++ b/src/commands/add/auth/clerk/generators.ts
@@ -2,12 +2,16 @@ import { ComponentLibType } from "../../../../types.js";
import { formatFilePath, getFilePaths } from "../../../filePaths/index.js";
const generateMiddlewareTs = () => {
- return `import { authMiddleware } from "@clerk/nextjs";
+ return `import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server';
// This example protects all routes including api/trpc routes
// Please edit this to allow other routes to be public as needed.
-// See https://clerk.com/docs/references/nextjs/auth-middleware for more information about configuring your middleware
-export default authMiddleware({ ignoredRoutes: ["/"] });
+// See https://clerk.com/docs/references/nextjs/clerk-middleware for more information about configuring your middleware
+const isProtectedRoute = createRouteMatcher([]);
+
+export default clerkMiddleware((auth, req) => {
+ if (isProtectedRoute(req)) auth().protect();
+});
export const config = {
matcher: ['/((?!.+\\\\\.[\\\\\w]+$|_next).*)', '/', '/(api|trpc)(.*)'],
@@ -19,7 +23,7 @@ const generateSignInPageTs = () => {
export default function Page() {
return (
-
+
);
}`;
@@ -30,7 +34,7 @@ const generateSignUpPageTs = () => {
export default function Page() {
return (
-
+
);
}`;