Skip to content

Commit

Permalink
chore(nextjs): Warn for deprecated nextjs versions (#4657)
Browse files Browse the repository at this point in the history
  • Loading branch information
panteliselef authored Nov 27, 2024
1 parent 82a5502 commit a18d45e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/smooth-humans-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/nextjs': patch
---

Warn for deprecated support for `13.x` and `14.0.x` Next.js versions.
14 changes: 14 additions & 0 deletions packages/nextjs/src/app-router/client/ClerkProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use client';
import { ClerkProvider as ReactClerkProvider } from '@clerk/clerk-react';
import { inBrowser } from '@clerk/shared/browser';
import { logger } from '@clerk/shared/logger';
import { useRouter } from 'next/navigation';
import nextPackage from 'next/package.json';
import React, { useEffect, useTransition } from 'react';

import { useSafeLayoutEffect } from '../../client-boundary/hooks/useSafeLayoutEffect';
Expand All @@ -23,7 +26,18 @@ declare global {
}
}

const isDeprecatedNextjsVersion = nextPackage.version.startsWith('13.') || nextPackage.version.startsWith('14.0');

export const ClientClerkProvider = (props: NextClerkProviderProps) => {
if (isDeprecatedNextjsVersion) {
const deprecationWarning = `Clerk:\nYour current Next.js version (${nextPackage.version}) will be deprecated in the next major release of "@clerk/nextjs". Please upgrade to [email protected] or later.`;
if (inBrowser()) {
logger.warnOnce(deprecationWarning);
} else {
logger.logOnce(`\n\x1b[43m----------\n${deprecationWarning}\n----------\x1b[0m\n`);
}
}

const { __unstable_invokeMiddlewareOnAuthStateChange = true, children } = props;
const router = useRouter();
const push = useAwaitablePush();
Expand Down

0 comments on commit a18d45e

Please sign in to comment.