webpresence
v3.2.0
Published
Discord Rich Presence for websites - Show your browsing activity in Discord
Maintainers
Readme
🌐 WebPresence
✨ What is WebPresence?
WebPresence is a Node.js package that connects your browser to Discord, showing your current website in your Discord profile. When you browse websites like YouTube, GitHub, or Twitter, your Discord profile displays what you're doing with custom icons for each site.
🚀 Installation
Prerequisites
- Node.js (version 16 or higher)
- Discord desktop application
Option 1: Install as a Package (Recommended)
# Install globally
npm install -g webpresence
# Start the server
webpresence start
# Or start in daemon mode (runs in background)
webpresence start -dOption 2: Install from Source
# Clone the repository
git clone https://github.com/utkarshthedev/webpresence.git
cd webpresence/server
# Install dependencies
npm install
# Build the package
npm run build
# Start the server
npm start🔧 Usage
Command Line Interface (CLI)
WebPresence comes with a powerful CLI that makes it easy to control the server:
# Start the server
webpresence start
# Start in daemon mode (background)
webpresence start -d
# Configure to start automatically on system boot
webpresence autostart --enable
# Check server status
webpresence status
# Toggle Discord presence on/off
webpresence toggle --on
webpresence toggle --off
# Configure preferences
webpresence config --view
webpresence config --prefix "Browsing"
webpresence config --disable-site "example.com"
webpresence config --always-show "github.com"
# Stop the server
webpresence stop
# Get help
webpresence helpUsing as a JavaScript/TypeScript Module
WebPresence can be imported and used in your own Node.js applications:
// ESM
import WebPresence from "webpresence";
// Start the server
const { success, port } = await WebPresence.startServer();
if (success) {
console.log(`Server running on port ${port}`);
}
// Check status
const status = WebPresence.getServerStatus();
console.log(`Discord connected: ${status.discordConnected}`);
// Toggle presence
const result = await WebPresence.togglePresence(true);
console.log(`Presence enabled: ${result.enabled}`);
// Stop the server
await WebPresence.stopServer();TypeScript Support
WebPresence includes full TypeScript definitions:
import WebPresence, { UserPreferences, ServerConfig } from "webpresence";
// Update user preferences
const preferences: UserPreferences = {
prefixText: "Browsing",
disabledSites: ["example.com"],
alwaysEnabledSites: ["github.com"],
continuousTimer: true,
};
const result = await WebPresence.updatePreferences(preferences);🌟 Features
Daemon Mode
Run WebPresence in the background without keeping a terminal window open:
# Start in daemon mode
webpresence start -d
# Check daemon status
webpresence status
# Stop the daemon
webpresence stopThe daemon creates these files in your home directory:
~/.webpresence/webpresence.pid- Process ID of the daemon~/.webpresence/webpresence.log- Log file for daemon output
Autostart Configuration
Configure WebPresence to start automatically when your computer boots:
# Enable autostart
webpresence autostart --enable
# Disable autostart
webpresence autostart --disable
# Check autostart status
webpresence autostart --statusConfiguration Management
Access and modify configuration through the API:
import { config } from "webpresence";
// Get current configuration
const serverConfig = config.getServer();
const discordConfig = config.getDiscord();
const userPrefs = config.getUserPreferences();
// Update user preferences
config.updateUserPreferences({
prefixText: "Exploring",
continuousTimer: false,
});📚 API Reference
Core Functions
| Function | Description |
| ------------------------------------------------- | ---------------------------------- |
| startServer(options?: { port?: number }) | Start the WebPresence server |
| stopServer() | Stop the WebPresence server |
| isServerRunning() | Check if the server is running |
| getServerStatus() | Get current server status |
| togglePresence(enabled?: boolean) | Enable or disable Discord presence |
| updatePreferences(preferences: UserPreferences) | Update user preferences |
Configuration API
| Function | Description |
| ------------------------------------- | ------------------------- |
| config.getServer() | Get server configuration |
| config.getDiscord() | Get Discord configuration |
| config.getUserPreferences() | Get user preferences |
| config.updateUserPreferences(prefs) | Update user preferences |
📁 Project Structure
src/
├── api.ts # Main package entry point
├── index.ts # Server implementation
├── config/ # Configuration files
├── services/ # Core services (Discord, WebSocket)
├── data/ # Data files (site icons)
├── routes/ # API routes
└── utils/ # Utility functions👨💻 Development
Quick Development Setup
# Clone and setup
git clone https://github.com/utkarshthedev/webpresence.git
cd webpresence/server
npm install
# Start development server with hot reload
npm run devAvailable Scripts
| Script | Description |
|--------|-------------|
| npm run dev | Start development server with hot reload and verbose logging |
| npm run build | Build for production |
| npm run build:watch | Build with watch mode |
| npm run link:dev | Build and link package locally for CLI testing |
| npm run unlink:dev | Unlink local development package |
| npm run server:start | Start server using CLI (after linking) |
| npm run server:daemon | Start server in daemon mode |
| npm run server:status | Check server status |
Local Development Workflow
CLI Testing (Recommended):
npm run link:dev # Link package locally webpresence start -d # Test CLI commands webpresence status # Verify functionality npm run unlink:dev # Unlink when doneDevelopment Mode (For core development only):
npm run dev # Starts server with hot reload
Why CLI testing is preferred:
- Tests the actual user experience
- Validates complete package functionality
- Ensures CLI commands work correctly
Testing
# Run tests (coming soon)
npm test
# Manual testing (recommended method)
npm run link:dev # Link package locally
webpresence start -d # Start server via CLI
webpresence status # Test CLI commands
# Load browser extension and test functionality
npm run unlink:dev # Unlink when doneFor comprehensive development instructions, see the Developer Guide.
📋 Developer Resources
- Developer Guide - Complete development setup and workflow
- API Documentation - REST API and WebSocket reference
- Contributing Guide - Detailed instructions for contributors
- Site Icons Guide - How to add new website icons
- CLI Reference - All command-line options
- All Documentation - Complete documentation index
📝 Changelog
See CHANGELOG.md for a detailed list of changes in each version.
🤝 Contributing
Contributions are welcome! See the Contributing Guide for more information.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
👤 Author
Made with ❤️ by Utkarsh Tiwari
