Examples Overview
Welcome to the GUN examples collection! This section provides practical, working examples to help you understand how to build real-world applications with GUN.Getting Started
All examples are located in theexamples/ directory of the GUN repository. You can run them locally or explore the code to understand different patterns and use cases.
Running Examples Locally
- Clone the GUN repository:
- Install dependencies:
- Start the server:
- Open your browser to
http://localhost:8765
Available Examples
Basic Examples
Simple, minimal examples to understand core concepts:- Chat (
basic/chat.html) - Real-time chat application - Note (
basic/note.html) - Collaborative text editor - Meet (
basic/meet.html) - Video conferencing with WebRTC - Poll (
basic/poll.html) - Real-time polling application - Upload (
basic/upload.html) - File upload and sharing - Video (
basic/video.html) - Video streaming - Private (
basic/private.html) - Encrypted private messaging
Framework Examples
Examples using popular frontend frameworks:- React - Todo app, chat, and JSON viewer components
- Angular - Full Angular integration example
- React Native - Mobile app examples for iOS/Android
- Vue - Vue.js integration examples
- Vanilla JS - Pure JavaScript implementations
Server Examples
Different ways to set up a GUN server:- Express (
express.js) - GUN with Express.js - HTTP (
http.js) - Standalone HTTP server with clustering - Hapi (
hapi.js) - GUN with Hapi.js framework - Relay - SQLite-backed relay server example
Advanced Examples
- Iris - Decentralized social network (Twitter/Instagram clone)
- Space Game (
game/space.html) - Multiplayer space game - Infinite Scroll - Efficient pagination patterns
- Explorer - Visual database explorer
- Stats (
stats.html) - Real-time node statistics
Example Categories
Browse examples by use case:Real-time Collaboration
- Chat Application - Build a real-time chat
- Collaborative Editor - Build a Google Docs-style editor
- Todo App - Learn CRUD operations
Networking & P2P
- P2P Networking - Mesh networking and peer discovery
- WebRTC integration for video/audio
- Relay server configuration
Example Structure
Most examples follow this pattern:Best Practices
- Start Simple - Begin with basic examples before moving to complex ones
- Open Multiple Windows - See real-time sync by opening the same example in multiple browser windows
- Check the Console - Many examples log useful debugging information
- Read the Source - Examples are designed to be educational - read the code!
- Experiment - Modify examples to learn how GUN works
Tips for Learning
- Basic Examples: Perfect for understanding core GUN concepts
- Framework Examples: Learn how to integrate GUN with your preferred framework
- Server Examples: Understand different deployment options
- Advanced Examples: See production-ready patterns and architectures
Community Examples
The GUN community has created many additional examples:- Nick’s React Apps - Advanced React + GUN applications
- Iris Components - Reusable web components
Need Help?
If you get stuck:- Check the GUN documentation
- Join the community chat at chat.gun.eco
- Search GitHub issues
- Ask questions in the GUN forum
Next Steps
Chat App
Build a real-time chat application
Todo App
Learn CRUD operations with a todo list
Collaborative Editor
Build a real-time text editor
P2P Networking
Explore mesh networking patterns