diff --git a/docs/start/framework/react/guide/authentication.md b/docs/start/framework/react/guide/authentication.md index f42fbc220fe..b64f38c43e8 100644 --- a/docs/start/framework/react/guide/authentication.md +++ b/docs/start/framework/react/guide/authentication.md @@ -154,8 +154,14 @@ export function AuthProvider({ children }: { children: ReactNode }) { } export function useAuth() { + const hydrated = useHydrated() const context = useContext(AuthContext) + if (!context) { + if (!hydrated) { + const { data: user, isLoading, refetch } = useServerFn(getCurrentUserFn) + return { user, isLoading, refetch } + } throw new Error('useAuth must be used within AuthProvider') } return context