soundcloud-api-ts-next
    Preparing search index...

    Function useLike

    • Like or unlike a SoundCloud track. Requires authentication.

      Returns {
          error: Error | null;
          likeTrack: (trackId: string | number) => Promise<void>;
          loading: boolean;
          unlikeTrack: (trackId: string | number) => Promise<void>;
      }

      An object with likeTrack, unlikeTrack, loading, and error.

      import { useLike } from "soundcloud-api-ts-next";

      function LikeButton({ trackId }: { trackId: number }) {
      const { likeTrack, unlikeTrack, loading } = useLike();
      return (
      <button onClick={() => likeTrack(trackId)} disabled={loading}>
      ❤️ Like
      </button>
      );
      }