# Vue Auth0 example returns error

**URL:** <https://community.auth0.com/t/vue-auth0-example-returns-error/92229>\
**Category:** Get Help\
**Tags:** vue-3, vue, auth0\
**Created:** [October 12, 2022, 12:06pm UTC](https://community.auth0.com/t/vue-auth0-example-returns-error/92229 "2022-10-12T12:06:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cajawallace](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/cajawallace/32/34067_2.png) [@cajawallace](https://community.auth0.com/u/cajawallace)\
**Post date:** [October 12, 2022, 12:06pm UTC](https://community.auth0.com/t/vue-auth0-example-returns-error/92229/1 "2022-10-12T12:06:23Z")

</div>

Hello, i have copied the Vue SDK quickstart guide to the letter.

[Auth0 Vue SDK Quickstarts: Login](https://auth0.com/docs/quickstart/spa/vuejs/01-login)

I have installed the library via

```auto
 npm install @auth0/auth0-vue

```

then registered the plugin and copied the login page, attempting both regular and the options API. I get this error:

```auto
Cannot read properties of undefined (reading 'loginWithRedirect')

```

Did anybody else have the same issue? How do i register loginWithRedirect?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [October 27, 2022, 5:17pm UTC](https://community.auth0.com/t/vue-auth0-example-returns-error/92229/3 "2022-10-27T17:17:37Z")

</div>

Hi @cajawallace,

Welcome to the Auth0 Community!

Have you seen this issue on github? It looks like there are some solutions shared there 👇

> <https://github.com/auth0/auth0-spa-js/issues/52>
>
> Hey guys, 
> I've been switching the use the new auth0 login with hooks, when I t…ry to do something very similar to the example, I keep encountering the following error:
> 
> \*\*TypeError: Cannot read property 'loginWithRedirect' of undefined\*\*
> 
> It appears that auth0Client is never getting set, so I'm never able to call loginWithRedirect on it. My credentials appear to be correct, and I've been able to login previously with them, so I'm wondering why that is.
> 
> My code:
> 
> \`\`\`
> function Home(props) {
> const \[value, setValue\] = useState("");
> const { isAuthenticated, loginWithRedirect, logout } = useAuth0();
> const { sessionSubmitted, setSessionSubmitted } = useState(false);
> 
> function handleChange(event) {
> setValue(event.target.value);
> }
> 
> function handleSessionSubmit() {
> console.log("we are handling session submit");
> console.log(value);
> 
> props.history.push({
> pathname: "/session",
> search:
> "?" +
> new URLSearchParams({
> sessionId: value
> }).toString(),
> state: {
> sessionId: value
> }
> });
> }
> 
> return (
> \<div class="Home"\>
> {" "}
> \<div className="bar"\>
> \<AppBar
> position="static"
> style={{ background: "transparent", boxShadow: "none" }}
> \>
> \<Toolbar\>
> \<div className="title"\>
> \<Typography variant="title"\> Frindle \</Typography\>{" "}
> \</div\>{" "}
> \<Button onClick={() =\> loginWithRedirect({})}\>
> {" "}
> Sign Up{" "}
> \</Button\>{" "}
> \<Button onClick={() =\> loginWithRedirect({})}\>
> {" "}
> Login{" "}
> \</Button\>{" "}
> \</Toolbar\>{" "}
> \</AppBar\>{" "}
> \</div\>{" "}
> \<div className="sessionForm"\>
> \<form onSubmit={handleSessionSubmit}\>
> \<div className="text"\>
> \<TextField
> name="session"
> label="Session ID"
> value={value}
> onChange={handleChange}
> margin="normal"
> variant="outlined"
> /\>
> \</div\>{" "}
> \<div className="button"\>
> \<Button
> type="submit"
> color="primary"
> variant="outlined"
> className="button"
> \>
> Submit{" "}
> \</Button\>{" "}
> \</div\>{" "}
> \</form\>{" "}
> \</div\>{" "}
> \</div\>
> );
> }
> 
> export default withRouter(Home);
> \`\`\`

---

<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:** [November 28, 2022, 8:53pm UTC](https://community.auth0.com/t/vue-auth0-example-returns-error/92229/4 "2022-11-28T20:53:56Z")

</div>

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