A Svelte library for integrating with Plebbit, enabling you to create subplebbits, fetch and publish posts, comments, and replies and solves default Captchas. This library is an experimental port of the [plebbit-react-hooks](https://github.com/plebbit/ple
npm install pleblib-svelteA Svelte library for integrating with Plebbit, enabling you to create subplebbits, fetch and publish posts, comments, and replies and solves default Captchas. This library is an experimental port of the plebbit-react-hooks leveraging plebbit-js
Remark: This library was experimentally ported by RooCode AI (Claude Sonnet 4.0). Unfortunately, it is not yet ported completely and consistently. It is not fully tested, but can serve as an experimental package to evaluate Plebbit-JS for decentralized social blogging and other social media formats.
It might be replaced with better version at some point. It can serve as a first demo on how to use Plebbit-JS within Svelte!
At the time of writing, a plebbit node (Plebbit-Cli) is necessary for plebbit-js to connect via websocket.
Current version of plebbit-js might work in a local-first way with integrated Helia (IPFS node) running in the browser. This is still untested!
``bash`
npm install pleblib-svelte
2. Run plebbit-cli using Docker Compose which will be available at ws://localhost:9138 and get the auth-key from ./data/plebbit directory
`bash`
docker-compose up -d `
3. Rename .env.example to .env
4. Run the development server withsvelte
{status}
Plebbit Demo
`
Before using the library, you need to initialize Plebbit:
`typescript
import { initPlebbit } from 'pleblib-svelte';
// Initialize Plebbit with default options
await initPlebbit();
// Or with custom options
await initPlebbit({
plebbitWsEndpoint: 'wss://your-plebbit-websocket-server.com',
ipfsGatewayUrls: [
'https://cloudflare-ipfs.com',
'https://ipfs.io'
]
});
`
Here's a complete example of how to list posts from a subplebbit:
`svelte
Subplebbit Viewer
{#if loading}
Loading subplebbit...
Error: {error.message}
{subplebbitInfo.description}
No posts found
{post.content || 'No Content'}
`
To publish a comment or post:
`typescript
import { publishComment } from 'pleblib-svelte';
await publishComment({
subplebbitAddress: 'news.eth',
title: 'My First Post', // Optional for posts
content: 'This is the content of my post',
parentCid: 'QmParentCommentCid' // Optional for replies
});
`
`bashClone the repository
git clone https://github.com/yourusername/pleblib-svelte.git
cd pleblib-svelte
MIT