-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(nextjs): Warn for deprecated nextjs versions (#4657)
- Loading branch information
1 parent
82a5502
commit a18d45e
Showing
2 changed files
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
|
@@ -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(); | ||
|