Authentication & Setup

1. Setup and Configure Axios

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

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

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:

Create a query client following the TanStack Query documentationarrow-up-right.

Last updated