šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Book a DemoInstallSign in
Socket

@auth0/nextjs-auth0

Package Overview
Dependencies
Maintainers
40
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@auth0/nextjs-auth0

Auth0 Next.js SDK

4.8.0
latest
Source
npm
Version published
Weekly downloads
318K
11.14%
Maintainers
40
Weekly downloads
Ā 
Created

What is @auth0/nextjs-auth0?

@auth0/nextjs-auth0 is a library that provides authentication and authorization for Next.js applications using Auth0. It simplifies the process of integrating Auth0 into Next.js apps by providing a set of tools and utilities for handling user sessions, protecting routes, and managing user profiles.

What are @auth0/nextjs-auth0's main functionalities?

User Authentication

This feature allows you to handle user authentication with Auth0. The `handleAuth` function sets up the necessary routes for login, logout, and callback.

const { handleAuth } = require('@auth0/nextjs-auth0');

export default handleAuth();

Protecting API Routes

This feature allows you to protect API routes by ensuring that only authenticated users can access them. The `withApiAuthRequired` function wraps your API route handler to enforce authentication.

import { withApiAuthRequired } from '@auth0/nextjs-auth0';

export default withApiAuthRequired((req, res) => {
  res.status(200).json({ message: 'This is a protected API route' });
});

Protecting Pages

This feature allows you to protect Next.js pages by ensuring that only authenticated users can access them. The `withPageAuthRequired` function wraps your page component to enforce authentication.

import { withPageAuthRequired } from '@auth0/nextjs-auth0';

const ProtectedPage = () => {
  return <div>This is a protected page</div>;
};

export default withPageAuthRequired(ProtectedPage);

Fetching User Profile

This feature allows you to fetch and display the authenticated user's profile information. The `useUser` hook provides the user's data, loading state, and any errors.

import { useUser } from '@auth0/nextjs-auth0';

const UserProfile = () => {
  const { user, error, isLoading } = useUser();

  if (isLoading) return <div>Loading...</div>;
  if (error) return <div>{error.message}</div>;

  return (
    <div>
      <h1>{user.name}</h1>
      <p>{user.email}</p>
    </div>
  );
};

export default UserProfile;

Other packages similar to @auth0/nextjs-auth0

Keywords

auth0

FAQs

Package last updated on 04 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts