Skip to main content
SDK v7.x · Last verified March 2026 · iOS · Android · Web · Flutter
// 1. Create a community
const { data: community } = await CommunityRepository.createCommunity({
  displayName: 'Gaming Hub', isPublic: true,
  postSetting: CommunityPostSettings.ANYONE_CAN_POST,
});

// 2. Join a community
await CommunityRepository.joinCommunity('communityId');

// 3. Query trending communities
CommunityRepository.getTrendingCommunities(
  { limit: 10 },
  ({ data }) => { /* render */ }
);
Full walkthrough below ↓
Platform note — code samples below use TypeScript. Every method has an equivalent in the iOS (Swift), Android (Kotlin), and Flutter (Dart) SDKs — see the linked SDK reference in each step.
Communities are the organizational backbone of social apps. This guide walks through the full lifecycle: create a community, grow its membership, set governance rules, and help users discover it.

Data Model

Prerequisites: SDK installed and authenticated → SDK Setup. By default, all authenticated users can create communities.
After completing this guide you’ll have:
  • Community creation flow (public and private) with categories
  • Member join/leave and role assignment wired up
  • Trending and recommended communities discoverable in-app

Quick Start: Create a Community

Use AmityCommunityRepository to create a community with privacy and moderation settings: Full reference → Create Community

Step-by-Step Implementation

1

Choose community settings

Pick the right postSettings for your community type before creating it. This controls the entire content governance model.
postSettingsWho can postBest for
ANYONE_CAN_POSTAll membersOpen communities
ADMIN_REVIEW_POST_REQUIREDAll members, but posts need approvalCurated communities
ONLY_ADMIN_CAN_POSTAdmins/moderators onlyAnnouncement channels
TypeScript
import { CommunityRepository } from '@amityco/ts-sdk';

const { data: community } = await CommunityRepository.createCommunity({
  displayName: 'My Community',
  isPublic: true,
  postSetting: 'ANYONE_CAN_POST',   // or 'ADMIN_REVIEW_POST_REQUIRED'
});
Full reference → Create Community
2

Add categories

Categorizing communities improves discoverability. Fetch available categories, then set category IDs on creation.
TypeScript
import { CategoryRepository } from '@amityco/ts-sdk';

const unsubscriber = CategoryRepository.getCategories(
  {},
  ({ data: categories, loading }) => {
    if (categories) { /* render category picker */ }
  },
);
Full reference → Community Categories
3

Handle membership — join and leave

For public communities, join is immediate. For private communities, joining sends a request that moderators can accept or reject.
TypeScript
import { CommunityRepository } from '@amityco/ts-sdk';

const unsub = CommunityRepository.getCommunity(communityId, async (response) => {
  const community = response.data;
  await community.join();
  unsub();
});
Full reference → Join / Leave Community
4

Manage member roles

Promote members to moderator or admin, ban members, or remove them from the community.
TypeScript
import { CommunityRepository } from '@amityco/ts-sdk';

await CommunityRepository.Membership.addMembers(communityId, ['userId1', 'userId2']);
Full reference → Member Management
5

Invite members (private communities)

For private communities, invite specific users by their user IDs. Invitees receive a notification and can accept or decline.
TypeScript
// Send invitations to users
await community.createInvitations(['userId1', 'userId2']);
Full reference → Community Invitation
6

Discover communities

Query trending and recommended communities for an explore page, or browse by category.
TypeScript
import { CommunityRepository } from '@amityco/ts-sdk';

const unsubscriber = CommunityRepository.getTrendingCommunities(
  { limit: 5 },
  ({ data: communities, loading }) => {
    if (communities) { /* render trending section */ }
  },
);
Full reference → Trending & Recommended Communities · Query Communities

Connect to Moderation & Analytics

Admin Console — Community management
The Admin Console gives moderators a full view of every community: member lists, post queues (when ADMIN_REVIEW_POST_REQUIRED is set), banned users, and community settings.Admin Console: Social Management
Subscribe to community.created, member.joined, member.left, and post.flagged webhook events to sync community state with your own backend or trigger automation.Webhook Events
Subscribe users to community push notifications so they’re alerted when new posts are approved or when they’re mentioned.Community Notification Settings

Common Mistakes

Creating communities without setting postSetting — If you omit postSetting, the default may prevent regular members from posting. Always specify ANYONE_CAN_POST or ADMIN_REVIEW_POST_REQUIRED explicitly.
Joining private communities without handling the pending statejoinCommunity on a private community returns a pending request, not immediate membership. Your UI should show a “Request Sent” state instead of community content.
Querying communities without filter — Without a filter, getCommunities returns all communities including ones the user isn’t a member of. Use filter: 'member' when building “My Communities” views.

Best Practices

  • Default new communities to public unless your use case requires private — discoverability drives growth
  • Use ADMIN_REVIEW_POST_REQUIRED for communities with compliance requirements (e.g., healthcare, finance)
  • Define clear community guidelines and surface them during the join flow
  • Assign at least two moderators per community to avoid single-point-of-failure moderation
  • Cache category lists — they change infrequently
  • Paginate member queries (queryMembers) with a reasonable page size (20-50)
  • Use Live Collections for member counts so they update in real-time without manual refresh
  • Show the member count and post count on community cards to signal activity level
  • Surface trending communities on the home screen to drive initial engagement
  • Send an in-app notification when a private community approves a join request

Dive deeper: Communities API Reference has full parameter tables, method signatures, and platform-specific details for every API used in this guide.

Next Steps

Your next step → Roles, Permissions & Governance

Communities are live — now set up moderator roles, post review gating, and ban management.
Or explore related guides:

Build a Social Feed

Query and render the community feed

Rich Content Creation

Let community members create posts

Content Moderation Pipeline

Set up moderation for community content