Custom Feeds
This guide will introduce the concept of Custom Feeds and how to create and manage them.
This guide provides an introduction to the concept of Custom Feeds. More information will be provided in due course.
As mentioned in the Feed concept page, there are two classes of Feed instances:
The Global Feed: The familiar shared feed that aggregates all public Lens activity.
Custom Feeds: App or community-specific feeds that can be open or governed by Feed Rules.
Create a Custom Feed
To create an Feed, you need to:
Create an Feed Metadata object
Upload the Feed Metadata object onto a public URI.
Deploy the Lens Feed smart contract.
See the Lens Metadata Standards guide for more information on creating and hosting Metadata objects.
- TS/JS
- JSON Schema
Use the @lens-protocol/metadata package to construct a valid FeedMetadata object:
Example
import { feed } from "@lens-protocol/metadata";
const metadata = feed({ name: "XYZ", title: "Not Just Another Feed… or is it?", description: "My custom feed description",});
Then, upload the Feed Metadata object to a public URI.
import { storageClient } from "./storage-client";
const { uri } = await storageClient.uploadAsJson(metadata);
console.log(uri); // e.g., lens://4f91ca…
This example uses Lens Storage to host the Metadata object. See the Lens Metadata Standards guide for more information on hosting Metadata objects.
You MUST be authenticated as Builder to make this request.
- TypeScript
- GraphQL
- React
Use the createFeed action to deploy the Lens Feed smart contract.
- TypeScript
- GraphQL
- React
Finally, handle the result using the adapter for the library of your choice:
See the Transaction Lifecycle guide for more information on how to determine the status of the transaction.
Fetch a Feed
- TypeScript
- GraphQL
- React
Use the fetchFeed action to fetch a single Feed by address or by transaction hash.
Search Feeds
- TypeScript
- GraphQL
- React
Use the paginated fetchFeeds action to search for feeds.
Continue with the Pagination guide for more information on how to handle paginated results.