@auth0/auth0-vue

中文文档
2.13.0发布于 2026/10/30MITTypeScriptESM + CJS构建来源已验证近 30 天下载 49.2万

Auth0 SDK for Vue Applications using Authorization Code Grant Flow with PKCE

原始使用文档
文档目录13 节
  1. Documentation
  2. Getting started
  3. Requirements
  4. Installation
  5. Configure Auth0
  6. Configure the SDK
  7. Add login to your application
  8. Experiment Center
  9. API reference
  10. Feedback
  11. Contributing
  12. Raise an issue
  13. Vulnerability Reporting

Auth0 SDK for Vue 3 Single Page Applications

Release Codecov Ask DeepWiki Downloads License CircleCI

📚 Documentation - 🚀 Getting Started - 💻 API Reference - 💬 Feedback

Documentation

  • Quickstart - our interactive guide for quickly adding login, logout and user information to a Vue 3 app using Auth0.
  • Sample App - a full-fledged Vue 3 application integrated with Auth0.
  • FAQs - frequently asked questions about the auth0-vue SDK.
  • Examples - code samples for common Vue 3 authentication scenario's.
  • Docs site - explore our docs site and learn more about Auth0.

Getting started

Requirements

This library supports Vue 3 applications. For integrating Auth0 with a Vue 2 application, please read the Vue 2 Tutorial.

Installation

Using npm:

npm install @auth0/auth0-vue

Using yarn:

yarn add @auth0/auth0-vue

Configure Auth0

Create a Single Page Application in the Auth0 Dashboard.

If you're using an existing application, verify that you have configured the following settings in your Single Page Application:

  • Click on the "Settings" tab of your application's page.
  • Scroll down and click on the "Show Advanced Settings" link.
  • Under "Advanced Settings", click on the "OAuth" tab.
  • Ensure that "JsonWebToken Signature Algorithm" is set to RS256 and that "OIDC Conformant" is enabled.

Next, configure the following URLs for your application under the "Application URIs" section of the "Settings" page:

  • Allowed Callback URLs: http://localhost:3000
  • Allowed Logout URLs: http://localhost:3000
  • Allowed Web Origins: http://localhost:3000

These URLs should reflect the origins that your application is running on. Allowed Callback URLs may also include a path, depending on where you're handling the callback (see below).

Take note of the Client ID and Domain values under the "Basic Information" section. You'll need these values in the next step.

Configure the SDK

Create an instance of the Auth0Plugin by calling createAuth0 and pass it to Vue's app.use().

import { createAuth0 } from '@auth0/auth0-vue';

const app = createApp(App);

app.use(
  createAuth0({
    domain: '<AUTH0_DOMAIN>',
    clientId: '<AUTH0_CLIENT_ID>',
    authorizationParams: {
      redirect_uri: '<MY_CALLBACK_URL>'
    }
  })
);

app.mount('#app');

Add login to your application

In order to add login to your application you can use the loginWithRedirect function that is exposed on the return value of useAuth0, which you can access in your component's setup function.

<script>
  import { useAuth0 } from '@auth0/auth0-vue';

  export default {
    setup() {
      const { loginWithRedirect } = useAuth0();

      return {
        login: () => {
          loginWithRedirect();
        }
      };
    }
  };
</script>

Once setup returns the correct method, you can call that method from your component's HTML.

<template>
  <div>
    <button @click="login">Log in</button>
  </div>
</template>
Using Options API
<template>
  <div>
    <button @click="login">Log in</button>
  </div>
</template>

<script>
  export default {
    methods: {
      login() {
        this.$auth0.loginWithRedirect();
      }
    }
  };
</script>

Experiment Center

[!NOTE] Experiment Center support via SDKs is currently in Early Access. To request access to this feature, contact your Auth0 representative.

You can also force a specific Experiment Center variant per login by passing experiment_id, variation_id, and the optional segment_id in authorizationParams - see the Experiment Center example.

For more code samples on how to integrate the auth0-vue SDK in your Vue 3 application, have a look at our examples.

API reference

Explore public API's available in auth0-vue.

Feedback

Contributing

We appreciate feedback and contribution to this repo! Before you get started, please see the following:

Raise an issue

To provide feedback or report a bug, please raise an issue on our issue tracker.

Vulnerability Reporting

Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.


Auth0 Logo

Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout Why Auth0?

This project is licensed under the MIT license. See the LICENSE file for more info.

版本与发布记录

@auth0/auth0-vue 共发布 29 个版本,首次发布于 2022/02/11;过去 12 个月发布了 10 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.13.0latest2026/10/308 天前
2.12.02026/10/2612 天前
2.11.02026/09/281 个月前
2.10.02026/09/171 个月前
2.9.02026/07/203 个月前
2.8.02026/07/034 个月前

其他发布通道:beta → 2.0.0-beta.0。

关于 @auth0/auth0-vue 的常见问题

@auth0/auth0-vue 是什么?

Auth0 SDK for Vue Applications using Authorization Code Grant Flow with PKCE

如何安装 @auth0/auth0-vue?

在项目目录运行 npm install @auth0/auth0-vue,或使用 pnpm add / yarn add / bun add。

@auth0/auth0-vue 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@auth0/auth0-vue 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@auth0/auth0-vue 可以商用吗?

@auth0/auth0-vue 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@auth0/auth0-vue 的下载量有多少?

根据 npm 官方下载统计,@auth0/auth0-vue 在 2026/10/07 – 2026/11/05 这 30 天内被下载 491,883 次,日均约 16,396 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@auth0/auth0-vue 还在维护吗?

最新版本 2.13.0 发布于 2026/10/30(8 天前);至今共发布 29 个版本,其中过去 12 个月发布了 10 个;首次发布于 2022/02/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。