A complete Ripple application template with Shogun Core integration, featuring real-time data synchronization, user authentication, and modern UI components.
- Ripple Framework: Modern reactive UI framework with TypeScript support
- Shogun Core Integration: Real-time data synchronization with GunDB
- User Authentication: Complete auth system with session persistence
- DaisyUI Components: Beautiful, accessible UI components
- Dark/Light Mode: Toggle between themes with persistence
- Real-time Counter: Demonstrates live data synchronization
- Modern Tooling: Vite, Prettier, and TypeScript configured
- Node.js >= 20.0.0
- npm, yarn, or pnpm
npm install
# or
yarn install
# or
pnpm installnpm run dev
# or
yarn dev
# or
pnpm devThe application will be available at http://localhost:3000
npm run build
# or
yarn build
# or
pnpm buildnpm run serve
# or
yarn serve
# or
pnpm servesrc/
βββ hooks/ # Custom Ripple hooks
β βββ useGunAuth.ripple # Authentication hook
β βββ useGunData.ripple # Data management hook
β βββ useGunInstance.ripple # GunDB instance hook
β βββ useSessionPersistence.ripple # Session management
βββ App.ripple # Main application component
βββ index.ts # Application entry point
βββ app.css # Global styles
The application connects to multiple GunDB peers for redundancy:
const shogun = useGunInstance({
peers: [
'https://relay.shogun-eco.xyz/gun',
'https://peer.wallie.io/gun',
'https://v5g5jseqhgkp43lppgregcfbvi.srv.us/gun'
],
appScope: 'shogun-ripple-boilerplate'
});The app supports light and dark themes with automatic system preference detection:
// Theme initialization
effect(() => {
const savedTheme = localStorage.getItem('theme');
const systemTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
const initialTheme = savedTheme || systemTheme;
@currentTheme = initialTheme;
document.documentElement.setAttribute('data-theme', initialTheme);
});Handles user authentication with session persistence:
const { user, isLoggedIn, login, signup, logout, loading } = useGunAuth(shogun);Features:
- Automatic session restoration
- Login/signup with validation
- Real-time auth state updates
- Error handling
Manages real-time data synchronization:
const { data, loading, error, put, get, remove, set } = useGunData(shogun, 'path', defaultValue);Features:
- Real-time data updates
- CRUD operations (put, get, remove, set)
- Loading and error states
- Automatic reconnection
Creates and manages GunDB instances:
const shogun = useGunInstance({
peers: ['peer1', 'peer2'],
appScope: 'my-app'
});Features:
- Singleton pattern for global instance
- Multiple peer connections
- Application scoping
- Auto-initialization
Manages session restoration and monitoring:
const { isSessionRestored, sessionError, retrySessionRestore } = useSessionPersistence(shogun);Features:
- Session status monitoring
- Automatic retry logic
- Error reporting
- Session validation
The demo counter showcases real-time data synchronization:
// Counter operations
const incrementCounter = async () => {
if (@isLoggedIn) {
const currentValue = @counterData?.value || 0;
const newValue = currentValue + 1;
await putCounterData({
value: newValue,
lastUpdated: new Date().toISOString()
});
}
};Built with DaisyUI form components:
<div class='form-control w-full'>
<label class='label'>
<span class='label-text'>Username</span>
</label>
<input
type='text'
placeholder='Enter your username'
value={@authUsername}
onInput={(e) => @authUsername = e.target.value}
class='input input-bordered w-full'
/>
</div>const toggleTheme = () => {
const newTheme = @currentTheme === 'light' ? 'dark' : 'light';
@currentTheme = newTheme;
// Apply theme to document
document.documentElement.setAttribute('data-theme', newTheme);
// Save preference
localStorage.setItem('theme', newTheme);
};<button onClick={toggleTheme} class='btn btn-ghost btn-circle'>
{#if @currentTheme === 'light'}
<svg><!-- Moon icon --></svg>
{:else}
<svg><!-- Sun icon --></svg>
{/if}
</button>This template includes Prettier with the Ripple plugin for consistent code formatting.
npm run format- Format all filesnpm run format:check- Check if files are formatted correctly
Prettier is configured in .prettierrc:
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 100,
"tabWidth": 4,
"plugins": ["prettier-plugin-ripple"]
}For the best development experience, install:
- User Registration/Login: Users can sign up or log in with username/password
- Session Persistence: Sessions are automatically restored on page refresh
- Real-time Auth State: Authentication state updates in real-time across components
- Secure Logout: Clean session termination with state reset
The boilerplate demonstrates real-time data synchronization:
- User Space: Data is stored in the user's personal space
- Real-time Updates: Changes sync instantly across all connected clients
- Offline Support: Data persists and syncs when connection is restored
- Conflict Resolution: GunDB handles data conflicts automatically
# Create production build
npm run build
# Preview build locally
npm run serveThe app connects to public GunDB peers by default. For production, consider:
- Setting up your own GunDB relay
- Configuring custom peers
- Implementing additional security measures
- Client-side Authentication: Auth is handled client-side with GunDB
- Data Encryption: GunDB provides end-to-end encryption
- Peer Selection: Use trusted peers for production deployments
- Session Management: Sessions are tied to browser storage
- Ripple Documentation - Ripple framework docs
- Vite Documentation - Build tool documentation
- DaisyUI Documentation - UI component library
- GunDB Documentation - Database documentation
- Shogun Core - Core integration library
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Join our community discussions
Happy coding with Shogun Ripple Boilerplate! π