npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mastodon-community-next

v0.0.7-beta

Published

NextJS SDK for using mastodon apis

Downloads

168

Readme

Mastodon Community Next

Next.js SDK for interacting with Mastodon APIs.
This package makes it simple to fetch timelines, post updates, and integrate Mastodon features directly into your Next.js apps.


📑 Table of Contents


📦 Installation

Install the package via npm, yarn, or pnpm:

# npm
npm install mastodon-community-next

# yarn
yarn add mastodon-community-next

# pnpm
pnpm add mastodon-community-next

⚠️ Additional Peer Dependencies (Required)

These packages are required for the SDK to work properly. Install only the ones you need:

# Install React Query
npm install @tanstack/react-query@^5.84.1
# or
yarn add @tanstack/react-query@^5.84.1

# Install React Toastify
npm install react-toastify@^11.0.5
# or
yarn add react-toastify@^11.0.5

# Install Feather Icons React
npm install feather-icons-react@^0.9.0
# or
yarn add feather-icons-react@^0.9.0

🚀 Quick Start

Wrap your app with the provider:

import { MastodonCommunityProvider } from "mastodon-community-next";

export default function App() {
  return (
    <MastodonCommunityProvider data={{ apiBasePath: "/api" }}>
      <YourApp />
    </MastodonCommunityProvider>
  );
}

📌 Usage

Components

  • CreatePost – UI for creating a new post
  • EditPost – UI for editing an existing post
  • TrendingHashtags – Displays trending hashtags
  • TabSection – Tabbed layout container
  • PostDetail – Detailed view of a single post
  • Lists Components:
    • Trending
    • Following
    • Bookmarks
    • LikedPosts
    • MyPosts
    • PublicTimeline

Example – Display trending posts:

import { Trending } from "mastodon-community-next";

export default function Home() {
  return <Trending />;
}

Hooks

  • useTrendingPosts – Fetch infinite trending posts
  • useBookmarksPosts – Fetch infinite bookmarked posts
  • useFollowingPosts – Fetch infinite posts from followed accounts
  • useHashtagTimeline – Fetch posts by hashtag
  • useLikedPosts – Fetch infinite liked posts
  • useMyPosts – Fetch your own posts
  • usePublicTimeline – Fetch public timeline posts

Example – Use infinite trending posts hook:

import { useTrendingPosts } from "mastodon-community-next";

export default function TrendingFeed() {
  const { data, fetchNextPage, hasNextPage } = useTrendingPosts();

  return (
    <div>
      {data?.pages.map(page =>
        page.posts.map(post => <div key={post.id}>{post.content}</div>)
      )}
      {hasNextPage && <button onClick={fetchNextPage}>Load more</button>}
    </div>
  );
}

⚙️ Context Options

The MastodonCommunityProvider accepts a data object with the following options:

  • apiBasePath (string) – Base path for Mastodon API requests
  • postDetailPath (string) – URL path for post details
  • postEditPath (string) – URL path for editing posts
  • userProfilePath (string) – URL path for user profiles
  • usernameNotAvailableHandler (() => void) – Callback when username is unavailable
  • themeMode ("light" | "dark") – Theme mode for the SDK
  • token (string) – Optional authentication token
  • mastodonId (string) – Optional Mastodon user ID
  • avatar (string) – Optional avatar URL
  • localization (object) – Custom localization values
  • customClasses (CustomClasses) – Override default CSS class names
  • colors (ThemeColors) – Custom light theme colors
  • darkColors (ThemeColors) – Custom dark theme colors
  • isUsernameAvailable (() => boolean) – Optional function to check username availability

Example – Customize provider with theme and classes:

import { MastodonCommunityProvider } from "mastodon-community-next";

const contextData = {
  apiBasePath: "/api",
  themeMode: "dark",
  customClasses: { createPostContainer: "my-create-post" },
  colors: { "--orange-orange-primary-100-light": "#ff6600" },
};

export default function App() {
  return (
    <MastodonCommunityProvider data={contextData}>
      <YourApp />
    </MastodonCommunityProvider>
  );
}

✨ Features

  • Easy integration with Mastodon APIs
  • Built for Next.js 14+
  • Infinite scroll hooks for posts and timelines
  • Prebuilt UI components for posts, lists, and hashtags
  • Customizable theme and class names via context
  • Notifications powered by react-toastify
  • Feather icons support

📜 License

ISC © 2025 ActTrader