A modern, privacy-focused pastebin application built on the Nostr protocol with advanced cloud storage capabilities. Share code snippets, text, and documents with complete data ownership and privacy, featuring seamless synchronization across devices through decentralized storage providers.
- Nostr Extension Support: Compatible with browser extensions like nos2x and Alby
- Private Key Login: Direct private key authentication for advanced users
- URL Hash Login: Quick access via URL fragment for testing and development
- DID Document Discovery: Automatically discovers custom storage endpoints from nostr.social
- Smart Fallbacks: Gracefully degrades from custom storage β nosdav.net β localStorage
- JSON-LD Schema: Semantic paste structure with proper metadata
- Syntax Highlighting: Support for 20+ programming languages with highlight.js
- Multi-Language Support: JavaScript, Python, Java, C++, HTML, CSS, SQL, and more
- Live Preview: Real-time syntax highlighting in view mode
- Search & Filter: Find pastes by title or content
- URL Sharing: Generate shareable links for any paste
- File Export: Download pastes as text files
- Copy to Clipboard: One-click URL copying
- Persistent Links: Pastes remain accessible via direct URLs
- Clean Interface: Minimalist design focused on content
- Responsive Design: Works seamlessly on desktop and mobile
- Dark Code Themes: GitHub-style syntax highlighting
- Intuitive Navigation: Easy switching between create, edit, and list views
- Download or clone this repository
- Open
index.html
in any modern web browser - Login with your Nostr extension or private key
- Start creating and sharing your pastes!
Visit the live demo: Pastebin Demo
Access with specific storage URI:
pastebin.html?paste=your-paste-id
- Frontend Framework: Vanilla JavaScript with Preact components
- UI Library: Preact 10.13.1 with HTM for JSX-like syntax
- Styling: TailwindCSS with custom CSS variables
- Syntax Highlighting: Highlight.js with GitHub theme
- Storage Protocol: Nosdav (Nostr-based WebDAV)
- Authentication: Nostr protocol with secp256k1 cryptography
- Dependencies: All loaded from CDN (no build process required)
DID Discovery β Custom Storage β nosdav.net β localStorage
- DID Document Fetching: Queries nostr.social for custom storage endpoints
- Smart URL Building: Constructs storage URLs with proper authentication
- Graceful Fallbacks: Multiple fallback levels ensure data availability
URL Hash β Nostr Extension β Private Key Input β Storage Access
index.js
: Main PastebinApp component with state managementnavbar.js
: Authentication and navigation componentstorage-config.js
: Centralized storage configuration with DID discoverynosdav-shim.js
: Fetch interceptor for Nostr authentication headers
pastebin/
βββ index.html # Main entry point with styling
βββ index.js # Core application logic
βββ navbar.js # Navigation and authentication
βββ storage-config.js # Storage discovery and URL building
βββ nosdav-shim.js # Fetch interceptor for Nostr auth
βββ package.json # Package configuration
βββ LICENSE # MIT License
βββ README.md # This file
The recommended method for regular users:
- Install a Nostr extension (nos2x, Alby, etc.)
- Click "Sign In"
- Grant permission for the app to access your identity
For advanced users who manage their own keys:
- Enter your 64-character hex private key
- Key is stored locally and used for authentication
- Warning: Only use on trusted devices
Quick access for development and testing:
pastebin.html#your-64-character-private-key-here
The hash is automatically removed from the URL for privacy.
The app automatically discovers your custom storage provider:
- Fetches your DID document from
nostr.social/.well-known/did/nostr/{pubkey}.json
- Looks for
Storage
service type in the service array - Uses the
serviceEndpoint
as your storage root - Falls back to
nosdav.net
if no custom storage is found
{
"@context": {
"Paste": "https://schema.org/CreativeWork",
"title": "https://schema.org/name",
"content": "https://schema.org/text"
},
"@type": "Paste",
"@id": "paste-123",
"title": "Example Code Snippet",
"content": "console.log('Hello, World!');",
"language": "javascript",
"created": "2025-01-27T10:30:00Z",
"updated": "2025-01-27T10:35:00Z"
}
{
"@context": {
"Paste": "https://schema.org/CreativeWork",
"title": "https://schema.org/name",
"content": "https://schema.org/text"
},
"@type": "PasteCollection",
"@id": "#this",
"pastes": [...],
"updated": "2025-01-27T10:30:00Z"
}
- Click "New Paste" or start typing
- Add a descriptive title
- Select the appropriate language for syntax highlighting
- Paste or type your content
- Press Ctrl+S (Cmd+S on Mac) or click "Save Paste"
- View All: Click "My Pastes" to see all saved pastes
- Search: Use the search box to filter by title or content
- Edit: Click "Edit" on any paste to modify it
- Share: Click "Share" to copy the paste URL
- Export: Click "Export" to download as a text file
- Delete: Click "Delete" to remove a paste permanently
Ctrl+S
/Cmd+S
: Save current pasteEscape
: Cancel editingEnter
: Confirm title changes
- Open
index.html
directly in browser - All dependencies loaded from CDN
- Changes are immediately visible on refresh
Check browser console for detailed logs:
- DID document fetching
- Storage provider selection
- Save/load operations
Follow the existing patterns:
- Use Preact with HTM for components
- Add state to the main PastebinApp component
- Include proper error handling and fallbacks
- Update collection metadata when appropriate
- Error saving: Check your Nostr extension connection
- Data not syncing: Verify your storage provider is accessible
- Pastes not loading: Check browser console for error messages
- Extension not detected: Install a compatible Nostr extension
- Private key errors: Ensure key is exactly 64 hex characters
- Login fails: Clear browser cache and try again
- Slow loading: DID documents are cached for 5 days
- Storage timeouts: Falls back to localStorage automatically
- Large pastes: Content is efficiently handled and indexed
This project welcomes contributions! Areas for improvement:
- Additional programming language support
- Enhanced UI/UX features
- Mobile responsiveness improvements
- Additional export formats
- Integration with other Nostr applications
- Themes and customization options
MIT License - see LICENSE file for details.
Built with β€οΈ on the decentralized web using Nostr protocol