# Quick Start

Stream lets you build activity feeds at scale. The largest apps using Stream have over 100 million users.
Stream Activity Feeds scales effectively while giving you more flexibility over the content shown in your feed.

<Admonition type="tip">

Stream Feeds has two halves. Feed groups, ranking, permissions and push setup are configured on your backend with a [server-side SDK](https://getstream.io/activity-feeds/docs/node/), authenticated with your API secret. The code you ship to your users is a [client SDK](https://getstream.io/activity-feeds/docs/javascript/), and it connects with a token signed on that backend. Whichever half you are here for, this sidebar carries an overview of the other.

</Admonition>

## Start here

<Cards>
  <Card size="small" icon="pulse" title="Activities" description="The core content units in Stream Feeds: posts, photos, videos, polls and any custom type you define." href="https://getstream.io/activity-feeds/docs/php/activities/" />
  <Card size="small" icon="file-list-3" title="Feeds" description="Collections of activities: personal, timeline, notification or custom feeds for your use case." href="https://getstream.io/activity-feeds/docs/php/feeds/" />
  <Card size="small" icon="key-2" title="Authentication and tokens" description="Your backend signs the tokens users connect with, using your API secret." href="https://getstream.io/docs/platform/authentication/" />
</Cards>

## Getting started

For SDK-accurate examples generated from the OpenAPI spec, use the Stream snippets reference: [TypeScript SDK - Feeds API](https://getstream.github.io/snippets/feeds/node/). Replace `node` in the URL with the SDK language you want to inspect.

<Tabs>

```js label="React (feeds-client)"
import { FeedsClient } from "@stream-io/feeds-client";

const client = new FeedsClient("<API key>");
await client.connectUser({ id: "john" }, "<user token>");

// Create a feed (or get its data if exists)
const feed = client.feed("user", "john");
// Subscribe to WebSocket events for state updates
await feed.getOrCreate({ watch: true });

// Add activity
await feed.addActivity({
  text: "Hello, Stream Feeds!",
  type: "post",
});
```

```js label="React Native (feeds-client)"
import { FeedsClient } from "@stream-io/feeds-client";

const client = new FeedsClient("<API key>");
await client.connectUser({ id: "john" }, "<user token>");

// Create a feed (or get its data if exists)
const feed = client.feed("user", "john");
// Subscribe to WebSocket events for state updates
await feed.getOrCreate({ watch: true });

// Add activity
await feed.addActivity({
  text: "Hello, Stream Feeds!",
  type: "post",
});
```

```php label="PHP"
use GetStream\ClientBuilder;
use GetStream\GeneratedModels;

$feedsClient = (new ClientBuilder())
    ->apiKey($apiKey)
    ->apiSecret($apiSecret)
    ->buildFeedsClient();


// Create a feed (or get its data if exists)
$feed = $feedsClient->feed("user", "john");
$feed->getOrCreateFeed(
    new GeneratedModels\GetOrCreateFeedRequest(userID: "john")
);

// Add activity
$response = $feedsClient->addActivity(new GeneratedModels\AddActivityRequest(
    type: 'post',
    feeds: ['user:john'],
    text: 'Hello, Stream Feeds!',
    userID: 'john'
));
```

</Tabs>

## Key concepts

### Activities

[Activities](https://getstream.io/activity-feeds/docs/php/activities/) are the core content units in Stream Feeds. They can represent posts, photos, videos, polls, and any custom content type you define.

### Feeds

[Feeds](https://getstream.io/activity-feeds/docs/php/feeds/) are collections of activities. They can be personal feeds, timeline feeds, [notification feeds](https://getstream.io/activity-feeds/docs/php/notification-feeds/), or custom feeds for your specific use case.

### Real-time updates

Stream Feeds provides [real-time updates](https://getstream.io/activity-feeds/docs/php/events/) through WebSocket connections, ensuring your app stays synchronized with the latest content.

### Social features

Built-in support for [reactions](https://getstream.io/activity-feeds/docs/php/reactions/), [comments](https://getstream.io/activity-feeds/docs/php/comments/), [bookmarks](https://getstream.io/activity-feeds/docs/php/bookmarks/), and [polls](https://getstream.io/activity-feeds/docs/php/polls/) makes it easy to build engaging social experiences.

## Server-side vs client-side

Most API calls can be made client-side. Client-side API calls use the permission system. Server-side API calls have full access.

```mermaid
flowchart LR
  subgraph app[Your app]
    client[Client SDK]
  end
  subgraph backend[Your backend]
    server[Server-side SDK]
  end
  client <--> api[Stream API]
  server --> api
  server -. user token .-> client
```

Most apps will default to making API calls client-side. Engineers will often use server-side to do the following tasks:

- Updating feed groups or feed views for ranking and aggregation
- Syncing users
- Returning tokens for authenticating users
- Writing to feeds that do not belong to the current user (since the user does not have access client side to do this)

## Common use cases

### Social media feed

```php label="PHP"
$feedsClient = (new ClientBuilder())
    ->apiKey($apiKey)
    ->apiSecret($apiSecret)
    ->buildFeedsClient();


// Create timeline feed
$timeline = $feedsClient->feed("timeline", "john");
$response = $timeline->getOrCreateFeed(
    new GeneratedModels\GetOrCreateFeedRequest(userID: "john")
);

// Add a reaction to activity
$reactionResponse = $feedsClient->addActivityReaction(
    "activity_123",
    new GeneratedModels\AddReactionRequest(
        type: "like",
        userID: "john"
    )
);

// Add a comment to activity
$commentResponse = $feedsClient->addComment(
    new GeneratedModels\AddCommentRequest(
        objectID: "activity_123",
        objectType: 'activity',
        comment: 'Great post!',
        userID: 'john'
    )
);

// Add a reaction to comment
$commentReactionResponse = $feedsClient->addCommentReaction(
    $commentResponse->getData()->comment->id,
    new GeneratedModels\AddCommentReactionRequest(
        type: "love",
        userID: "john"
    )
);
```

### Notification feed

```php label="PHP"
// Create a notification feed
$notifications = $feedsClient->feed("notification", "john");
$notifications->getOrCreateFeed(
    new GeneratedModels\GetOrCreateFeedRequest(userID: "john")
);

// Mark notifications as read
$markResponse = $notifications->markActivity(
    new GeneratedModels\MarkActivityRequest(markAllRead: true, userID: "john")
);
```

### Polls

```php label="PHP"
$feedsClient = (new ClientBuilder())
    ->apiKey($apiKey)
    ->apiSecret($apiSecret)
    ->buildFeedsClient();

$client = (new ClientBuilder())
    ->apiKey($apiKey)
    ->apiSecret($apiSecret)
    ->build();

// Create a poll
$poll = new GeneratedModels\CreatePollRequest(
    name: 'What is your favorite color?',
    userID: 'john',
    options: [
        new GeneratedModels\PollOptionInput("Red"),
        new GeneratedModels\PollOptionInput("Blue"),
        new GeneratedModels\PollOptionInput("Green"),
    ]
);
$pollResponse = $client->createPoll($poll);
$pollData = $pollResponse->getData();
$pollId = $pollData->poll->id;

// Create activity with the poll
$pollActivity = new GeneratedModels\AddActivityRequest(
    type: 'poll',
    feeds: ['user:john'],
    pollID: $pollId,
    text: 'What is your favorite color?',
    userID: 'john'
);
$response = $feedsClient->addActivity($pollActivity);

// Vote on the poll
$activityData = $response->getData();
$activityId = $activityData->activity->id;
$optionId = $pollData->poll->options[0]->id;

$voteResponse = $feedsClient->castPollVote($activityId, $pollId,
    new GeneratedModels\CastPollVoteRequest(
        vote: new GeneratedModels\VoteData(optionID: $optionId),
        userID: "john"
    )
);
```

## Advanced features

### Custom activity types

Create custom activity types to represent your app's specific content:

```php label="PHP"
// Create a feed (or get its data if exists)
$feed = $feedsClient->feed("user", "john");
$feed->getOrCreateFeed(
    new GeneratedModels\GetOrCreateFeedRequest(userID: "john")
);

// Add custom activity
$feedsClient->addActivity(
    new GeneratedModels\AddActivityRequest(
        type: "workout",
        text: "Just finished my run",
        userID: "john",
        feeds: ["user:john"],
        custom: (object)[
            "distance" => 5.2,
            "duration" => 1800,
            "calories" => 450,
        ],
    )
);
```

### Real-time updates with the state layer

Only for client-side SDKs

```js label="JavaScript"
const feed = client.feed("user", "john");
// Subscribe to WebSocket events for state updates
await feed.getOrCreate({ watch: true });
feed.state.subscribe((state) => {
  // Called everytime the state changes
  console.log(state);
});

// or if you only want to observe part of the state
feed.state.subscribeWithSelector(
  (state) => ({
    activities: state.activities,
  }),
  (state, prevState) => {
    console.log(state.activities, prevState?.activities);
  },
);

// Current state
console.log(feed.state.getLatestValue());
```

## What's next

<Cards>
  <Card size="small" icon="team" title="Follow and unfollow" description="Connect feeds with follow relationships to build timeline experiences." href="https://getstream.io/activity-feeds/docs/php/follows/" />
  <Card size="small" icon="notification-3" title="Notification feeds" description="Create notification feeds and mark activities as read." href="https://getstream.io/activity-feeds/docs/php/notification-feeds/" />
  <Card size="small" icon="shield-user" title="Permissions and roles" description="The subject, resource and action model, built-in and custom roles." href="https://getstream.io/docs/platform/permissions/" />
</Cards>

## FAQ

**Which feed groups are built in?**

`user`, `timeline`, `foryou`, `notification`, `story` and `stories`. The [feeds page](https://getstream.io/activity-feeds/docs/php/feeds/#built-in-feed-groups) describes each.

**Can I rank a feed?**

Yes, on paid plans. A feed group takes a [ranking expression](https://getstream.io/activity-feeds/docs/node/custom-ranking/) such as `decay_linear(time) * popularity`.

**How much custom data fits on an activity?**

The whole activity, built-in and custom fields together, must stay under 10KB at write time. Bigger objects go in [collections](https://getstream.io/activity-feeds/docs/php/collections/), though collection data can't be used in ranking or aggregation.

**Can users comment on and react to activities?**

Yes. [Comments](https://getstream.io/activity-feeds/docs/php/comments/) support threading and [reactions](https://getstream.io/activity-feeds/docs/php/reactions/) work on activities and comments alike.

**How do I migrate from Feeds v2?**

From the dashboard, which replicates live v2 traffic to v3 while you integrate. The [migration guide](https://getstream.io/activity-feeds/docs/node/v2-to-v3-migration/) covers the phases.

**Can feed content be moderated?**

Yes. Moderation is built in through `client.moderation`. See [moderation](https://getstream.io/activity-feeds/docs/php/moderation/).


---

This page was last updated at 2026-09-09T16:01:02.051Z.

For the most recent version of this documentation, visit [https://getstream.io/activity-feeds/docs/php/](https://getstream.io/activity-feeds/docs/php/).