A powerful library for building decentralized applications that can run seamlessly across browser, server, and peer environments.
- Multi-context Support: Run your app in browser, server, or peer environments with a unified API.
- Reactive UI: Build dynamic user interfaces with a reactive component system.
- Distributed State Management: Easily manage and synchronize state across multiple peers.
- Peer-to-Peer Communication: Seamless P2P networking with built-in WebRTC support.
- Plugin System: Extend your app's functionality with a flexible plugin architecture.
- Development Tools: Comprehensive toolset for debugging and monitoring your decentralized apps.
- TypeScript Support: Full TypeScript support for enhanced developer experience.
npm install @nomyx/decentranet
or
yarn add @nomyx/decentranet
Here's a simple example to get you started with a decentralized chat application:
import { DecentralizedApp, Component, GunDataProvider } from '@nomyx/decentranet';
class ChatComponent extends Component<{ messages: string[] }, {}> {
constructor(contexts: string[], dataProvider: GunDataProvider) {
super(contexts, dataProvider, { messages: [] }, {});
}
render(): string {
return `
<div>
${this.state.messages.map(msg => `<p>${msg}</p>`).join('')}
</div>
<input id="messageInput" type="text">
<button onclick="sendMessage()">Send</button>
`;
}
sendMessage(message: string) {
this.setState({ messages: [...this.state.messages, message] });
}
}
const app = new DecentralizedApp(new GunDataProvider());
app.initialize().then(() => {
const chatComponent = new ChatComponent(['browser'], app.gunDataProvider);
chatComponent.mount(document.getElementById('app')!);
app.start();
});
For more detailed information about using @nomyx/decentranet, please refer to our comprehensive guide.
Detailed API documentation can be found here.
Check out our examples directory for more complex usage scenarios and best practices.
We welcome contributions! Please see our Contributing Guide for more details.
@nomyx/decentranet is MIT licensed.
If you encounter any issues or have questions, please file an issue on our GitHub issue tracker.
@nomyx/decentranet is built on top of several amazing open-source projects, including GunDB, WebRTC, and many others. We're grateful for their contributions to the open-source community.
- Follow us on Twitter for updates
- Join our Discord community for discussions and support
Happy decentralized app building!