/
v3.0.11Get access

Quickstart

Time to first call: ~3 min

Content SDK reads CMS content over HTTP. Initialize it once with your API URL, then read menus, banners, promotions and SEO entries through the useContent hook.

Show samples as
1

Install the package

Installation guide

Content, Casino and Swarm ship in one package, so a single install covers every surface.

.sh
npm install @softconstruct/betchain-core-client
Registry access firstThe package comes from a private registry. Configure the @softconstruct scope and your BetChain license key before installing.
2

Initialize the CMS client

Web: call initCMSContent once at app start. Flutter: a single initSDK brings up the content CMS client (cmsContentCore) along with the socket session.

.ts
1import { initCMSContent } from '@softconstruct/betchain-core-client/content';2 3initCMSContent({4  version: 2,5  partner: 18749451,6  apiUrl: 'https://cms-api.your-host.com'7});

Parameters

NameTypeRequiredDescription
apiUrlstringYesBase URL of your CMS API.
version1 | 2YesCMS content version to read from.
partnernumberYesYour partner identifier in the CMS.
3

Read CMS content

Pass the method reference to useContent. The hook returns data, loading and error state typed from that method.

.ts
1import { getPromotions } from '@softconstruct/betchain-core-client/content';2import { useContent } from '@softconstruct/betchain-core-client/hooks';3 4const usePromotions = () => {5  const { data, isLoading, hasError, message } = useContent(getPromotions, {6    params: { language: 'eng' },7    dependencies: []8  });9 10  return { data, isLoading, hasError, message };11};
RefetchingValues in dependencies trigger a refetch when they change — pass the current language or platform when your app can switch them at runtime.
4

Handle errors

The useContent hook exposes hasError and message. A direct call returns the raw CMS envelope instead — check message and errors, and treat a null data as a failure.

.ts
1import { useEffect } from 'react';2import { getPromotions } from '@softconstruct/betchain-core-client/content';3import { useContent } from '@softconstruct/betchain-core-client/hooks';4 5const usePromotions = () => {6  const { data, hasError, message, isLoading } = useContent(getPromotions, {7    params: { language: 'eng' },8    dependencies: []9  });10 11  useEffect(() => {12    if (hasError) {13      console.error('Content request failed:', message);14    }15  }, [hasError, message]);16 17  return { data, isLoading, hasError };18};

What next

Was this page helpful?