Common Scenarios

Learn how to manage common scenarios when working with Lens Graph.


Profile Followers

Get profiles that are following a specified profile ID.

You can use the useProfileFollowers hook to get the followers of a profile.

Available in @lens-protocol/react-web and @lens-protocol/react-native

import { useProfileFollowers } from '@lens-protocol/react-web';
const { data, loading, error } = useProfileFollowers({  of: '0x123',});

The hook yields a PaginatedReadResult<Profile[]>. For more information on pagination, refer to this guide.

Profile Following

Get the list of profiles that a specific profile ID is following.

You can use the useProfileFollowing hook to get the profiles that a specific user is following.

Available in @lens-protocol/react-web and @lens-protocol/react-native

import { useProfileFollowing } from '@lens-protocol/react-web';
const { data, loading, error } = useProfileFollowing({  for: '0x123',});

The hook yields a PaginatedReadResult<Profile[]>. For more information on pagination, refer to this guide.

Mutual Followers

Get the list of profiles that are mutually followed by two specified profiles.

You can use the useMutualFollowers hook to retrieve the followers that two profiles have in common.

Available in @lens-protocol/react-web and @lens-protocol/react-native

import { useMutualFollowers } from '@lens-protocol/react-web';
const { data, loading, error } = useMutualFollowers({  observer: '0x123',  viewing: '0x456',});

The hook yields a PaginatedReadResult<Profile[]>. For more information on pagination, refer to this guide.

Bulk Follow Status

Get the follow status for multiple pairs of profiles in a single operation.

You can use the client.profile.followStatusBulk method to retrieve the follow status for multiple profile pairs in a single operation.

import { development, LensClient } from '@lens-protocol/client';
const client = new LensClient({  environment: development,});
const result = await client.profile.followStatusBulk({  followInfos: [    {      follower: '0x06', // is 0x06 following 0x38?      profileId: '0x38',    },    {      follower: '0x38', // is 0x38 following 0x06?      profileId: '0x06',    },  ],});

Profile Followed Status

You can check the profile.operations.isFollowedByMe property of a profile to determine if the active profile is following it. Refer to Profile Operations for more details.

Note: isFollowedByMe is meaningful only when authenticated.

Profile Following Status

You can check the profile.operations.isFollowingMe property of a profile to determine if it is following the active profile. Refer to Profile Operations for more details.

Note: isFollowingMe is meaningful only when authenticated.


That's it—you now have a solid understanding of how to handle common scenarios when working with Lens Graph.