A Svelte adaptation of plebbit-react-hooks that provides reactive stores for building decentralized applications with Plebbit.
npm install plebbit-svelte-stores
# or
pnpm add plebbit-svelte-stores
# or
yarn add plebbit-svelte-stores
import { accountsStore, subplebbitsStore, commentsStore } from 'plebbit-svelte-stores';
// Create an account
const account = await accountsStore.createAccount({ name: 'My Account' });
// Create a subplebbit
const subplebbit = await subplebbitsStore.createSubplebbit({
title: 'My Community',
description: 'A place for discussion'
}, account);
// Publish a comment
const comment = await accountsStore.publishComment({
title: 'Hello World',
content: 'This is my first post!',
subplebbitAddress: subplebbit.address
});
accountsStore
Manages user accounts and authentication:
// Subscribe to accounts
$: accounts = $accountsStore.accounts;
$: activeAccount = $accountsStore.activeAccountId;
// Create account
await accountsStore.createAccount({ name: 'Username' });
// Publish content
await accountsStore.publishComment({
title: 'Post Title',
content: 'Post content',
subplebbitAddress: 'community.eth'
});
// Vote on comments
await accountsStore.vote('comment-cid', 1); // upvote
subplebbitsStore
Manages subplebbits (communities):
// Subscribe to subplebbits
$: subplebbits = $subplebbitsStore.subplebbits;
// Add subplebbit to store
await subplebbitsStore.addSubplebbitToStore('community.eth', account);
// Create new subplebbit
const subplebbit = await subplebbitsStore.createSubplebbit({
title: 'My Community',
description: 'Community description'
}, account);
// Edit subplebbit
await subplebbitsStore.editSubplebbit('community.eth', {
title: 'Updated Title'
}, account);
commentsStore
Manages comments and posts:
// Subscribe to comments
$: comments = $commentsStore.comments;
// Add comment to store
await commentsStore.addCommentToStore('comment-cid', account);
This repository includes a demo application that showcases creating a subplebbit about J.S. Bach's beautiful fugues and posting content about them.
# Clone the repository
git clone [repository-url]
cd plebbit-svelte-stores
# Install dependencies
pnpm install
# Start development server
pnpm run dev
The demo demonstrates:
The stores are built using Svelte's reactive store system and adapted from the React-based plebbit-react-hooks:
šÆ NEW: Full plebbit-cli integration is now available!
# 1. Setup with auto-generated auth key
./setup-plebbit.sh
# 2. Start plebbit-cli (requires Docker)
docker-compose up plebbit-cli -d
# 3. Start development server
pnpm run dev
The application automatically detects the best available connection method and displays the status in the UI.
The current implementation provides:
Contributions are welcome! Please feel free to submit issues and pull requests.
MIT License - see LICENSE file for details.