Skip to content

Commit

Permalink
feat(nextjs): Remove useAuth() error in dev (#4588)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacekradko authored Nov 16, 2024
1 parent 0c5429e commit afcc517
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/spotty-eagles-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/nextjs': patch
---

Removing error in dev when useAuth() is not wrapped in <ClerkProvider dynamic />
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useAuth } from '@clerk/clerk-react';
import { useDerivedAuth } from '@clerk/clerk-react/internal';
import type { InitialState } from '@clerk/types';
import { useRouter } from 'next/compat/router';
import { PHASE_PRODUCTION_BUILD } from 'next/constants';
import React from 'react';

const PromisifiedAuthContext = React.createContext<Promise<InitialState> | InitialState | null>(null);
Expand Down Expand Up @@ -72,11 +71,6 @@ export function usePromisifiedAuth() {
return useAuth();
}

if (!resolvedData && process.env.NEXT_PHASE !== PHASE_PRODUCTION_BUILD) {
throw new Error(
'Clerk: useAuth() called in static mode, wrap this component in <ClerkProvider dynamic> to make auth data available during server-side rendering.',
);
}
// We don't need to deal with Clerk being loaded here
return useDerivedAuth(resolvedData);
} else {
Expand Down

0 comments on commit afcc517

Please sign in to comment.