# loginWithRedirect is not a function

**URL:** <https://community.auth0.com/t/loginwithredirect-is-not-a-function/92465>\
**Category:** Get Help\
**Created:** [October 15, 2022, 3:45pm UTC](https://community.auth0.com/t/loginwithredirect-is-not-a-function/92465 "2022-10-15T15:45:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![snichols](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/snichols/32/33405_2.png) [@snichols](https://community.auth0.com/u/snichols)\
**Post date:** [October 15, 2022, 3:45pm UTC](https://community.auth0.com/t/loginwithredirect-is-not-a-function/92465/1 "2022-10-15T15:45:30Z")

</div>

Hello,

I am using @auth0/auth0-vue 1.0.2 I am creating a vue3 application.

I’ve been following this [tutorial](https://developer.auth0.com/resources/code-samples/full-stack/hello-world/basic-role-based-access-control/spa/vue-javascript-with-composition-api/express-javascript).

My main.js looks like this:

```auto
appInstance
.use(store)
.use(router)
.use(createAuth0({
      domain: VITE_AUTH0_DOMAIN,
      client_id: VITE_AUTH0_CLIENT_ID,
      redirect_uri: VITE_AUTH0_CALLBACK_URL,
      audience: VITE_AUTH0_AUDIENCE,
    })
  )
.use(VueSweetalert2)
.use(MaterialDashboard)
.mount("#app");

```

I create a login button like this:

```auto
<template>
  <button class="button__login" @click="handleLogin">Log In</button>
</template>

<script setup>
import { useAuth0 } from "@auth0/auth0-vue";
console.log(useAuth0)
const { loginWithRedirect } = useAuth0();

const handleLogin = () => {
  loginWithRedirect({
    prompt: "login",
    appState: {
      target: "/app/profile",
    },
  });
};
</script>

```

When I click the button I receive the following error: `Uncaught (in promise) TypeError: Cannot destructure property 'loginWithRedirect' of 'Object(...)(...)' as it is undefined.`

This makes it look like `useAuth0` is not being populated.

I also get this warning: `Vue warn]: inject() can only be used inside setup() or functional components.` - Which I thought I was doing.

Why is useAuth0 undefined?

---

<div class="post-metadata">

**Author:** ![snichols](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/snichols/32/33405_2.png) [@snichols](https://community.auth0.com/u/snichols)\
**Post date:** [October 16, 2022, 9:06pm UTC](https://community.auth0.com/t/loginwithredirect-is-not-a-function/92465/2 "2022-10-16T21:06:08Z")

</div>

I have it working. The issue is I was adding Auth0 to an existing vue3 project. The issues was caused by lower versions of some node\_modules than were being used in the demo project.

I wish I could tell you exactly what cause the issue, but after a day of troubleshooting you start to lose track.

The one small issues was package-lock.json. I ended up increasing the version numbers of the node\_modules in package.lock to match the demo project, deleting node\_modules, and deleting package-lock.json and running `npm i`

Probably not the recommend upgrade path, but it worked for me.

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [October 17, 2022, 8:47pm UTC](https://community.auth0.com/t/loginwithredirect-is-not-a-function/92465/3 "2022-10-17T20:47:45Z")

</div>

Thank you @snichols for sharing your solution with our Community! 👍 👏

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [October 31, 2022, 8:47pm UTC](https://community.auth0.com/t/loginwithredirect-is-not-a-function/92465/4 "2022-10-31T20:47:50Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
