XBorg SDK
  • Introduction
  • Community
    • Details
    • Resources
    • Inventory
    • Prizes
    • Store
    • Achievements
  • User
    • Profile
    • Authentication
    • Socials
    • Wallets
  • Quests
    • User
    • Community
  • Quest Events
    • Details
    • Participation
    • Leaderboard
  • Blockchain
  • Configuration
  • Shared Library SDK
    • Authentication & Setup
    • Quest Management
    • Event Management
      • Working with Events
      • Events Lifecycle
      • Events Requirements
      • Events Quests
      • Events Rewards
    • Quest Rewards
    • 3D Avatar
Powered by GitBook
On this page
  1. Shared Library SDK

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

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:

const apiContext = ApiBase.getInstance();
apiContext.setApi(api);
PreviousShared Library SDKNextQuest Management

Last updated 5 months ago

Create a query client following the .

TanStack Query documentation