Skip to Content
Packages@loop/stream

@loop/stream

GetStream integration for community activity feeds, notifications, and chat.

Installation

pnpm add @loop/stream

Client Setup

import { createStreamClient } from '@loop/stream'; const stream = createStreamClient({ apiKey: process.env.STREAM_API_KEY!, apiSecret: process.env.STREAM_API_SECRET!, });

Activity Feeds

Publishing Activities

import { publishActivity } from '@loop/stream'; await publishActivity({ actor: 'user:user_123', verb: 'created', object: 'stack:stack_456', data: { title: 'Recovery Stack', description: 'My BPC-157 + TB-500 protocol', }, });

Reading Feeds

import { getUserFeed, getTimelineFeed } from '@loop/stream'; // User's own feed (what they've done) const myFeed = await getUserFeed('user_123', { limit: 20 }); // Timeline feed (what people they follow have done) const timeline = await getTimelineFeed('user_123', { limit: 20 });

Following

import { followFeed, unfollowFeed } from '@loop/stream'; await followFeed('user_123', 'user_456'); // Follow a user await unfollowFeed('user_123', 'user_456'); // Unfollow

Notifications

import { getNotifications } from '@loop/stream'; const notifications = await getNotifications('user_123', { limit: 10 });

User Tokens

Generate client-side tokens for Stream SDK:

import { generateUserToken } from '@loop/stream'; const token = generateUserToken('user_123'); // Pass to client for real-time feed updates

Chat

import { createStreamClient } from '@loop/stream'; const client = createStreamClient(config); // Chat services for community messaging