> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cskn.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# User profile

> Read and update the signed-in user's profile.

## useUser

Fetches the signed-in user's profile. Cached for five minutes and retried once.

```tsx theme={null}
import { useBridgeAuth, useUser } from '@cskn/sdk';

function Profile() {
  const { isReady, token } = useBridgeAuth();
  const { data: user, isLoading, error } = useUser({ enabled: isReady && !!token });

  if (isLoading) return <Spinner />;
  if (error) return <p>Could not load your profile.</p>;
  return <h2>{user.name}</h2>;
}
```

<ParamField path="enabled" type="boolean" default="true">
  Pass `isReady && !!token` so the request waits for credentials.
</ParamField>

Query key: `['user', 'profile']`.

## useUpdateProfile

A mutation that saves profile fields and updates the cached profile with the server's answer.

```tsx theme={null}
import { useUpdateProfile } from '@cskn/sdk';

function EditName() {
  const { mutate, isPending } = useUpdateProfile();

  return (
    <button disabled={isPending} onClick={() => mutate({ name: 'New name' })}>
      {isPending ? 'Saving…' : 'Save'}
    </button>
  );
}
```

## useUserStore

Both hooks also write the profile into a small persisted [zustand](https://zustand.docs.pmnd.rs) store, which you can read anywhere without a query:

```tsx theme={null}
import { useUserStore } from '@cskn/sdk';

const user = useUserStore((s) => s.user);
const isAuthenticated = useUserStore((s) => s.isAuthenticated);
```

The store persists to `localStorage` under `cskn-user-storage`. Call `useUserStore.getState().logout()` to clear it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.