Learn about the recommendation features for Profiles in Lens.

Lens Recommendations

Lens Profile recommendations are generated by leveraging a user's social graph and engagement data. Machine learning is employed to rank potential profiles to follow, based on the likelihood and quality of interaction.

List All

The useRecommendedProfiles hook allows you to retrieve recommended Lens Profiles.

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

import { useRecommendedProfiles, profileId } from '@lens-protocol/react-web';
export function RecommendedProfiles() {  const { data, error, loading } = useRecommendedProfiles({    for: profileId('0x24'),  });
  if (loading) return <p>Loading...</p>;
  if (error) return <p>Error: {error.message}</p>;
  if (data.length === 0) return <p>No profiles found</p>;
  return (    <ul>      { => (        <li key={}>{profile.handle?.fullHandle}</li>      ))}    </ul>  );}

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

Dismiss Recommendations

When you dismiss recommended Lens Profiles, they are removed from your suggestions, and the recommendation algorithm adjusts accordingly.

You must be authenticated with a Profile to dismiss recommendations. See Profile Login for more information.

The useDismissRecommendedProfiles hook allows you to remove Lens Profiles from the list of recommended profiles.

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

import {  ProfileId,  useDismissRecommendedProfiles} from '@lens-protocol/react-web';
export function DismissRecommendedProfiles({ profileIds }: { profileIds: ProfileId[] }) {  const { execute, loading } = useDismissRecommendedProfiles();
  if (loading) return <p>Dismissing profile recommendations...</p>;
  return (    <button onClick={() => execute({ profileIds: profileIds })} disabled={loading}>      Dismiss profile recommendations    </button>  );}

Peer Recommendations

The Peer Recommendations feature was designed to strengthen community ties through peer-to-peer vetting. Users can recommend or unrecommend peers, fostering a more interconnected and supportive network. It's primarily used for building customized features like favorite contacts and more. Read on to learn how to use it.

You must be authenticated with a Profile to use Peer Recommendations. See Profile Login for more information.

Recommend a Profile

If you encounter a Lens Profile that you believe is worth recommending, you can use the available SDK hooks, methods, or API mutations to recommend them. If you later decide otherwise, you can also unrecommend the Profile.

You can use the useRecommendProfileToggle hook to recommend and unrecommend a Lens Profile.

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

import { Profile, useRecommendProfileToggle } from '@lens-protocol/react-web';
function ProfileRecommendation({ profile }: { profile: Profile }) {  const { execute: toggle, loading } = useRecommendProfileToggle();
  return (    <button onClick={() => toggle({ profile })} disabled={loading}>      {profile.peerToPeerRecommendedByMe ? `Remove recommendation` : `Recommend`}    </button>  );}

Recommendation Status

To determine if the active profile has recommended another profile, you can utilize the profile.peerToPeerRecommendedByMe property. This property is accessible in the Profile fragment of the SDKs and can be queried using the API, as shown in the example below. Note that this property will always return false if the current user is not authenticated.

query {  profile(request: { forProfileId: "0x01" }) {    id    peerToPeerRecommendedByMe  }}

That's it—you've now learned how to use the recommendation features, including how to retrieve, dismiss, and recommend profiles.