---
url: >-
  https://game-engine-io.github.io/enginex-frontend-sdk/reference/api/@getenginex/sdk-vue/functions/useUserKey.md
---
[Reference](../../../index.md) / [@getenginex/sdk-vue](../index.md) / useUserKey

# useUserKey()

> **useUserKey**(`namespace?`, `method?`): `ComputedRef`\<readonly `unknown`\[] | `null`>

Prefix of the current session user's keys, to invalidate or read from the cache: `null` without a session.
For the exact `setQueryData` key, use the factory's (`q.wallet.getBalance().queryKey`).

## Parameters

### namespace?

`MaybeRefOrGetter`<`string` | `undefined`>

Namespace, e.g. `'wallet'` (ref, getter or value).

### method?

`MaybeRefOrGetter`<`string` | `undefined`>

Method, e.g. `'getBalance'` (only with `namespace`).

## Returns

`ComputedRef`\<readonly `unknown`\[] | `null`>

Computed with `['enginex', 'user', userId, namespace?, method?]`, or `null` without a session.

## Throws

If called in an app without the `EnginexPlugin`.

## Example

```ts
const walletKey = useUserKey('wallet')
if (walletKey.value) queryClient.invalidateQueries({ queryKey: walletKey.value })
```
