Welcome to the Kinde community.

A
A
A
M
T

How do I access the $auth in the script

How do I access the $auth in the script tag of a nuxtjs application?
A
N
D
23 comments
@Niza
For NuxtJS applications integrated with Kinde, you can utilize the useKindeClient helper function to access authentication-related functionalities, similar to how you would work with $auth in the template. Here's an example of how you can use it:

Plain Text
<script setup>
import { useKindeClient } from '@nuxtjs/kinde'

const client = useKindeClient();

// Example of using the client to check if a user is logged in
const isLoggedIn = client.isLoggedIn();
</script>


This approach aligns with the Composition API's design, allowing you to interact with plugins and libraries in a composable manner.


@Daniel_Kinde might jump in with further details for you.
I get this
Module '"@nuxtjs/kinde"' has no exported member 'useKindeClient'. Did you mean to use 'import useKindeClient from "@nuxtjs/kinde"' instead?ts-plugin(2614)
Attachments
image.png
image.png
@Daniel_Kinde Any way I can about this?
@Niza You don't need to import useKindeClient due to Nuxt auto imports

Plain Text
<script setup lang="ts">
  const client = useKindeClient();
  const isLoggedIn = await client.isAuthenticated()
</script>


That should be all you need. Let me know if you have any further issues
Oh 🤦‍♂️ my bad
Is it supposed to be the any type?
Attachment
image.png
^
Attachment
image.png
I noticed when looking into this the typing was not working, I will look at what is happening there
When I CTRL click on it, it takes me to the nuxt imports list
Oh well, perhaps I should use useAuth. Let me try.
Attachment
image.png
Yes, useAuth will give you the loggedIn indicator also like this

Plain Text
<script setup lang="ts">
const authState = useAuth();
authState.loggedIn
</script>
Feel free to raise an issue on the module about the typing
I am assuming useKindeClient will allow me to execute commands that manipulate (CRUD) users in the Kinde database?
Add a reply
Sign up and join the conversation on Discord
Join
This approach aligns with the Composition API's design, allowing you to interact with plugins and libraries in a composable manner.@Daniel_Kinde might jump in with further details for you.","dateCreated":"2024-03-20T02:31:49.287Z","dateModified":"2024-03-20T02:31:49.287Z","author":{"@type":"Person","url":"https://community.kinde.com/members/4cdb0601-422b-4988-9290-07865a14f2ef","name":"Andre @ Kinde","identifier":"4cdb0601-422b-4988-9290-07865a14f2ef","image":"https://cdn.discordapp.com/avatars/700311363871965315/23231d5aca046d6e32d652451385e56a.webp?size=256"},"commentCount":0,"comment":[],"position":1,"upvoteCount":0},"1":{"@type":"Comment","text":"I get thisModule '\"@nuxtjs/kinde\"' has no exported member 'useKindeClient'. Did you mean to use 'import useKindeClient from \"@nuxtjs/kinde\"' instead?ts-plugin(2614)","dateCreated":"2024-03-20T12:44:05.652Z","dateModified":"2024-03-20T12:44:05.652Z","author":{"@type":"Person","url":"https://community.kinde.com/members/211bf886-31dc-4ab5-9700-d60005ca90e2","name":"Niza","identifier":"211bf886-31dc-4ab5-9700-d60005ca90e2","image":"https://cdn.discordapp.com/avatars/1197892383740805216/f0894274ed9a0cf5435677dfbd3bc78c.webp?size=256"},"commentCount":0,"comment":[],"position":2,"upvoteCount":0},"2":{"@type":"Comment","text":"","dateCreated":"2024-03-20T12:44:27.165Z","dateModified":"2024-03-20T12:44:27.165Z","author":{"@type":"Person","url":"https://community.kinde.com/members/211bf886-31dc-4ab5-9700-d60005ca90e2","name":"Niza","identifier":"211bf886-31dc-4ab5-9700-d60005ca90e2","image":"https://cdn.discordapp.com/avatars/1197892383740805216/f0894274ed9a0cf5435677dfbd3bc78c.webp?size=256"},"commentCount":0,"comment":[],"position":3,"upvoteCount":0},"3":{"@type":"Comment","text":"@Daniel_Kinde Any way I can about this?","dateCreated":"2024-03-20T14:44:29.499Z","dateModified":"2024-03-20T14:44:29.499Z","author":{"@type":"Person","url":"https://community.kinde.com/members/211bf886-31dc-4ab5-9700-d60005ca90e2","name":"Niza","identifier":"211bf886-31dc-4ab5-9700-d60005ca90e2","image":"https://cdn.discordapp.com/avatars/1197892383740805216/f0894274ed9a0cf5435677dfbd3bc78c.webp?size=256"},"commentCount":0,"comment":[],"position":4,"upvoteCount":0},"4":{"@type":"Comment","text":"@Niza You don't need to import useKindeClient due to Nuxt auto importsThat should be all you need. Let me know if you have any further issues","dateCreated":"2024-03-20T17:02:05.126Z","dateModified":"2024-03-20T17:02:05.126Z","author":{"@type":"Person","url":"https://community.kinde.com/members/7c4df9b2-9598-4c69-b525-570d253a0829","name":"Daniel_Kinde","identifier":"7c4df9b2-9598-4c69-b525-570d253a0829","image":"https://cdn.discordapp.com/avatars/1198941355452416033/36d1775f36f32a27d5c74288876338dc.webp?size=256"},"commentCount":0,"comment":[],"position":5,"upvoteCount":0},"5":{"@type":"Comment","text":"Oh 🤦‍♂️ my bad","dateCreated":"2024-03-20T17:24:08.950Z","dateModified":"2024-03-20T17:24:08.950Z","author":{"@type":"Person","url":"https://community.kinde.com/members/211bf886-31dc-4ab5-9700-d60005ca90e2","name":"Niza","identifier":"211bf886-31dc-4ab5-9700-d60005ca90e2","image":"https://cdn.discordapp.com/avatars/1197892383740805216/f0894274ed9a0cf5435677dfbd3bc78c.webp?size=256"},"commentCount":0,"comment":[],"position":6,"upvoteCount":0},"6":{"@type":"Comment","text":"Is it supposed to be the any type?","dateCreated":"2024-03-20T17:28:58.908Z","dateModified":"2024-03-20T17:28:58.908Z","author":{"@type":"Person","url":"https://community.kinde.com/members/211bf886-31dc-4ab5-9700-d60005ca90e2","name":"Niza","identifier":"211bf886-31dc-4ab5-9700-d60005ca90e2","image":"https://cdn.discordapp.com/avatars/1197892383740805216/f0894274ed9a0cf5435677dfbd3bc78c.webp?size=256"},"commentCount":0,"comment":[],"position":7,"upvoteCount":0},"7":{"@type":"Comment","text":"^","dateCreated":"2024-03-20T17:29:29.412Z","dateModified":"2024-03-20T17:29:29.412Z","author":{"@type":"Person","url":"https://community.kinde.com/members/211bf886-31dc-4ab5-9700-d60005ca90e2","name":"Niza","identifier":"211bf886-31dc-4ab5-9700-d60005ca90e2","image":"https://cdn.discordapp.com/avatars/1197892383740805216/f0894274ed9a0cf5435677dfbd3bc78c.webp?size=256"},"commentCount":0,"comment":[],"position":8,"upvoteCount":0},"8":{"@type":"Comment","text":"I noticed when looking into this the typing was not working, I will look at what is happening there","dateCreated":"2024-03-20T17:29:52.082Z","dateModified":"2024-03-20T17:29:52.082Z","author":{"@type":"Person","url":"https://community.kinde.com/members/7c4df9b2-9598-4c69-b525-570d253a0829","name":"Daniel_Kinde","identifier":"7c4df9b2-9598-4c69-b525-570d253a0829","image":"https://cdn.discordapp.com/avatars/1198941355452416033/36d1775f36f32a27d5c74288876338dc.webp?size=256"},"commentCount":0,"comment":[],"position":9,"upvoteCount":0},"9":{"@type":"Comment","text":"When I CTRL click on it, it takes me to the nuxt imports list","dateCreated":"2024-03-20T17:29:59.623Z","dateModified":"2024-03-20T17:29:59.623Z","author":{"@type":"Person","url":"https://community.kinde.com/members/211bf886-31dc-4ab5-9700-d60005ca90e2","name":"Niza","identifier":"211bf886-31dc-4ab5-9700-d60005ca90e2","image":"https://cdn.discordapp.com/avatars/1197892383740805216/f0894274ed9a0cf5435677dfbd3bc78c.webp?size=256"},"commentCount":0,"comment":[],"position":10,"upvoteCount":0},"10":{"@type":"Comment","text":"","dateCreated":"2024-03-20T17:30:31.126Z","dateModified":"2024-03-20T17:30:31.126Z","author":{"@type":"Person","url":"https://community.kinde.com/members/211bf886-31dc-4ab5-9700-d60005ca90e2","name":"Niza","identifier":"211bf886-31dc-4ab5-9700-d60005ca90e2","image":"https://cdn.discordapp.com/avatars/1197892383740805216/f0894274ed9a0cf5435677dfbd3bc78c.webp?size=256"},"commentCount":0,"comment":[],"position":11,"upvoteCount":0},"11":{"@type":"Comment","text":"Thanks","dateCreated":"2024-03-20T17:30:56.123Z","dateModified":"2024-03-20T17:30:56.123Z","author":{"@type":"Person","url":"https://community.kinde.com/members/211bf886-31dc-4ab5-9700-d60005ca90e2","name":"Niza","identifier":"211bf886-31dc-4ab5-9700-d60005ca90e2","image":"https://cdn.discordapp.com/avatars/1197892383740805216/f0894274ed9a0cf5435677dfbd3bc78c.webp?size=256"},"commentCount":0,"comment":[],"position":12,"upvoteCount":0},"12":{"@type":"Comment","text":"Oh well, perhaps I should use useAuth. Let me try.","dateCreated":"2024-03-20T17:31:52.964Z","dateModified":"2024-03-20T17:31:52.964Z","author":{"@type":"Person","url":"https://community.kinde.com/members/211bf886-31dc-4ab5-9700-d60005ca90e2","name":"Niza","identifier":"211bf886-31dc-4ab5-9700-d60005ca90e2","image":"https://cdn.discordapp.com/avatars/1197892383740805216/f0894274ed9a0cf5435677dfbd3bc78c.webp?size=256"},"commentCount":0,"comment":[],"position":13,"upvoteCount":0},"13":{"@type":"Comment","text":"It works","dateCreated":"2024-03-20T17:33:11.205Z","dateModified":"2024-03-20T17:33:11.205Z","author":{"@type":"Person","url":"https://community.kinde.com/members/211bf886-31dc-4ab5-9700-d60005ca90e2","name":"Niza","identifier":"211bf886-31dc-4ab5-9700-d60005ca90e2","image":"https://cdn.discordapp.com/avatars/1197892383740805216/f0894274ed9a0cf5435677dfbd3bc78c.webp?size=256"},"commentCount":0,"comment":[],"position":14,"upvoteCount":0},"14":{"@type":"Comment","text":"!!","dateCreated":"2024-03-20T17:33:12.911Z","dateModified":"2024-03-20T17:33:12.911Z","author":{"@type":"Person","url":"https://community.kinde.com/members/211bf886-31dc-4ab5-9700-d60005ca90e2","name":"Niza","identifier":"211bf886-31dc-4ab5-9700-d60005ca90e2","image":"https://cdn.discordapp.com/avatars/1197892383740805216/f0894274ed9a0cf5435677dfbd3bc78c.webp?size=256"},"commentCount":0,"comment":[],"position":15,"upvoteCount":0},"15":{"@type":"Comment","text":"Yes, useAuth will give you the loggedIn indicator also like this ","dateCreated":"2024-03-20T17:33:24.603Z","dateModified":"2024-03-20T17:33:24.603Z","author":{"@type":"Person","url":"https://community.kinde.com/members/7c4df9b2-9598-4c69-b525-570d253a0829","name":"Daniel_Kinde","identifier":"7c4df9b2-9598-4c69-b525-570d253a0829","image":"https://cdn.discordapp.com/avatars/1198941355452416033/36d1775f36f32a27d5c74288876338dc.webp?size=256"},"commentCount":0,"comment":[],"position":16,"upvoteCount":0},"16":{"@type":"Comment","text":"Great!","dateCreated":"2024-03-20T17:33:26.069Z","dateModified":"2024-03-20T17:33:26.069Z","author":{"@type":"Person","url":"https://community.kinde.com/members/7c4df9b2-9598-4c69-b525-570d253a0829","name":"Daniel_Kinde","identifier":"7c4df9b2-9598-4c69-b525-570d253a0829","image":"https://cdn.discordapp.com/avatars/1198941355452416033/36d1775f36f32a27d5c74288876338dc.webp?size=256"},"commentCount":0,"comment":[],"position":17,"upvoteCount":0},"17":{"@type":"Comment","text":"","dateCreated":"2024-03-20T17:33:30.060Z","dateModified":"2024-03-20T17:33:30.060Z","author":{"@type":"Person","url":"https://community.kinde.com/members/211bf886-31dc-4ab5-9700-d60005ca90e2","name":"Niza","identifier":"211bf886-31dc-4ab5-9700-d60005ca90e2","image":"https://cdn.discordapp.com/avatars/1197892383740805216/f0894274ed9a0cf5435677dfbd3bc78c.webp?size=256"},"commentCount":0,"comment":[],"position":18,"upvoteCount":0},"18":{"@type":"Comment","text":"true","dateCreated":"2024-03-20T17:33:34.058Z","dateModified":"2024-03-20T17:33:34.058Z","author":{"@type":"Person","url":"https://community.kinde.com/members/211bf886-31dc-4ab5-9700-d60005ca90e2","name":"Niza","identifier":"211bf886-31dc-4ab5-9700-d60005ca90e2","image":"https://cdn.discordapp.com/avatars/1197892383740805216/f0894274ed9a0cf5435677dfbd3bc78c.webp?size=256"},"commentCount":0,"comment":[],"position":19,"upvoteCount":0},"19":{"@type":"Comment","text":"Feel free to raise an issue on the module about the typing","dateCreated":"2024-03-20T17:33:45.062Z","dateModified":"2024-03-20T17:33:45.062Z","author":{"@type":"Person","url":"https://community.kinde.com/members/7c4df9b2-9598-4c69-b525-570d253a0829","name":"Daniel_Kinde","identifier":"7c4df9b2-9598-4c69-b525-570d253a0829","image":"https://cdn.discordapp.com/avatars/1198941355452416033/36d1775f36f32a27d5c74288876338dc.webp?size=256"},"commentCount":0,"comment":[],"position":20,"upvoteCount":0},"20":{"@type":"Comment","text":"Alright!","dateCreated":"2024-03-20T17:33:51.684Z","dateModified":"2024-03-20T17:33:51.684Z","author":{"@type":"Person","url":"https://community.kinde.com/members/211bf886-31dc-4ab5-9700-d60005ca90e2","name":"Niza","identifier":"211bf886-31dc-4ab5-9700-d60005ca90e2","image":"https://cdn.discordapp.com/avatars/1197892383740805216/f0894274ed9a0cf5435677dfbd3bc78c.webp?size=256"},"commentCount":0,"comment":[],"position":21,"upvoteCount":0},"21":{"@type":"Comment","text":"https://github.com/nuxt-modules/kinde/issues/74","dateCreated":"2024-03-20T18:00:22.010Z","dateModified":"2024-03-20T18:00:22.010Z","author":{"@type":"Person","url":"https://community.kinde.com/members/211bf886-31dc-4ab5-9700-d60005ca90e2","name":"Niza","identifier":"211bf886-31dc-4ab5-9700-d60005ca90e2","image":"https://cdn.discordapp.com/avatars/1197892383740805216/f0894274ed9a0cf5435677dfbd3bc78c.webp?size=256"},"commentCount":0,"comment":[],"position":22,"upvoteCount":0},"22":{"@type":"Comment","text":"I am assuming useKindeClient will allow me to execute commands that manipulate (CRUD) users in the Kinde database?","dateCreated":"2024-03-20T18:33:01.143Z","dateModified":"2024-03-20T18:33:01.143Z","author":{"@type":"Person","url":"https://community.kinde.com/members/211bf886-31dc-4ab5-9700-d60005ca90e2","name":"Niza","identifier":"211bf886-31dc-4ab5-9700-d60005ca90e2","image":"https://cdn.discordapp.com/avatars/1197892383740805216/f0894274ed9a0cf5435677dfbd3bc78c.webp?size=256"},"commentCount":0,"comment":[],"position":23,"upvoteCount":0},"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"How do I access the $auth in the script","datePublished":"2024-03-19T20:00:49.423Z","dateModified":"2024-03-19T20:00:49.423Z","commentCount":23,"text":"How do I access the $auth in the script tag of a nuxtjs application?","url":"https://community.kinde.com/kinde-discord-c8YCrDd9qJT1/how-do-i-access-the-auth-in-the-script-hcTPrXlxmgYd","identifier":"hcTPrXlxmgYd","publisher":{"@type":"Organization","name":"Kinde ","logo":{"@type":"ImageObject","url":"https://assets.usehall.com/org_01HZGQM95HD1MHM3BBA5TT9ED7/0efba1af-f172-46a5-8a4e-1ec0c85dc9e3.svg"}},"author":{"@type":"Person","url":"https://community.kinde.com/members/211bf886-31dc-4ab5-9700-d60005ca90e2","name":"Niza","identifier":"211bf886-31dc-4ab5-9700-d60005ca90e2","image":"https://cdn.discordapp.com/avatars/1197892383740805216/f0894274ed9a0cf5435677dfbd3bc78c.webp?size=256"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0}}]