An object containing:
leaderboard: Sorted leaderboard entries.saveScore: Function to add or update a player's score.clear: Function to reset the leaderboard.Clears all leaderboard entries.
Saves or updates a player's score.
If the player already exists, their score will only be updated if the new score is higher than the existing one.
React hook for managing a persistent leaderboard stored in localStorage.
Scores are stored under the
leaderboardkey and sorted in descending order. If a player already exists, their score is only updated if the new score is higher.