# Authentication & Setup

#### 1. **Setup and Configure Axios**

The package requires Axios to manage API calls. Install Axios (`"axios": "^1.7.4"`) and configure it:

```javascript
const api = axios.create(
  Object.assign({}, axiosConfig, {
    headers: {
      get: {
        "Accept-Language": "EN", // Set locale
      },
    },
  })
);

api.interceptors.request.use((config) => {
  config.headers["xb-tenant"] = ""; // TENANT is required
  config.headers.Authorization = `Bearer ${sessionToken}`;
  return config;
});

```

> **Note**: Axios is not bundled to reduce package size.

**Example API Call**

```javascript
import { getUserByHandle, PublicProfile } from "@xborglabs/ui-shared";

const publicProfile: PublicProfile = await getUserByHandle({
  api,
  userHandle: "easteregg",
  communityId: "abcdef",
});
```

> **Important**: Only imports from `@xborglabs/ui-shared` are SSR-compatible.

#### 2. **Configure TanStack Query Provider**

To use abstracted hooks, link your API configuration with the `apiContext`:

```javascript
const apiContext = ApiBase.getInstance();
apiContext.setApi(api);
```

Create a query client following the [TanStack Query documentation](https://tanstack.com/query/v5/docs/framework/react/installation).
