Interactive Demo
Try out FilePizza API below to share files peer-to-peer directly in your browser.
Features
- Peer-to-peer file sharing in the browser
- Easy setup for both file sending and receiving
- Password protection for secure file transfers
- Progress tracking for uploads and downloads
- Multi-file support
- Event-based architecture for easy integration
- Works with React, Next.js, and vanilla JavaScript
Installation
npm install filepizza-client
Usage
Uploading Files
import { FilePizzaUploader } from 'filepizza-client';
const uploader = new FilePizzaUploader({
filePizzaServerUrl: 'https://your-filepizza-server.com'
});
await uploader.initialize();
uploader.on('progress', (progressInfo) => {
console.log(`Upload progress: ${progressInfo.overallProgress * 100}%`);
});
uploader.setFiles(fileList); // From an input element
const links = uploader.getShareableLinks();
Downloading Files
import { FilePizzaDownloader } from 'filepizza-client';
const downloader = new FilePizzaDownloader({
filePizzaServerUrl: 'https://your-filepizza-server.com'
});
await downloader.initialize();
downloader.on('progress', (progressInfo) => {
console.log(`Download progress: ${progressInfo.overallProgress * 100}%`);
});
await downloader.connect(filePizzaUrl);
await downloader.startDownload();