Skip to content

Getting Started

Mehrdad Pajuhaan edited this page Oct 23, 2026 · 1 revision

Getting Started

This page takes you from installation to your first community calls: loading a community with its categories and searching its posts. It covers both a storefront setup (the most common case) and a standalone page.

Prerequisites

  • A Selldone shop with a community, or use the main Selldone community (ID 1) to experiment.
  • A browser application built with a bundler, and Node.js with npm or Yarn.
  • For actions on behalf of a member (posting, reacting, following), a signed-in customer session. In a storefront, the Storefront SDK handles this.

1. Install

npm install @selldone/sdk-community
yarn add @selldone/sdk-community

The package depends on @selldone/core-js, axios and lodash-es.

2. Configure the endpoints

Add these tags to the page head:

<meta name="service-url" content="https://selldone.com">
<meta name="selldone-capi" content="https://capi.selldone.com">
<!-- Only needed for embed links (CommunityURLs.PostEmbedUrl) -->
<meta name="selldone-iframe" content="https://iframe.selldone.com">
Meta tag Read by Purpose
selldone-capi window.CAPI Base URL of every community API route.
service-url CommunityURLs and Selldone Core Main Selldone URL, used for links.
selldone-iframe CommunityURLs.PostEmbedUrl() Base URL of embeddable posts.

As with the other Selldone SDKs, you can provide the same keys on window.selldone_config instead of meta tags.

3. Initialize

Inside a storefront

Set up the Storefront SDK first, then the Community SDK. This is the order used by the official Storefront:

import { StorefrontSDK } from "@selldone/sdk-storefront";
import { CapiCommunity } from "@selldone/sdk-community";

// ━━━ Storefront SDK (xapi) ━━━
StorefrontSDK.Setup();

// ━━━ Community SDK (capi) ━━━
CapiCommunity.Setup(); // Registers window.CAPI and window.$community

The Storefront SDK initializes Selldone Core and puts the customer's Authorization header on window.axios. The community requests use the same window.axios, so they are sent as the signed-in customer.

Standalone

import { SelldoneCore } from "@selldone/core-js";
import { CapiCommunity } from "@selldone/sdk-community";

SelldoneCore.Setup();
CapiCommunity.Setup();

// Optional: act as a signed-in user
window.axios.defaults.headers.common["Authorization"] = `Bearer ${ACCESS_TOKEN}`;

4. Load a community

// Resolve the community of the current shop (or 1, the main Selldone community)
const communityId = window.$community.getCommunityID(shop);

const { community, categories, data } = await window.$community.getInfo(communityId);

console.log(community.title, categories.map((c) => c.title));

getInfo accepts optional offset and days arguments that select the time window of the statistics returned in data (the Components community layout uses offset = 0 and days = 7 by default).

5. Search posts

let offset = 0;
const limit = 20;

const { posts, more } = await window.$community.post.searchPosts(communityId, offset, limit, "shipping");
// Load the next page while `more` is true

6. Call any other community route

const { data: feed } = await window.axios.get(window.CAPI.GET_COMMUNITY_FEED(communityId), {
  params: { offset: 0, limit: 10 },
});
if (feed.error) console.warn(feed.error_msg);

See Community API URL Builders for every route.

Next steps