Next.js compress before upload
Run compression in a client component ("use client") on the file input. The optimized File uploads via fetch or server action — the compression step never needs your server.
Comment ça marche
- Add compresso.js to your client form component
- Compress on select
- Submit result.file
Questions courantes
- Works with Server Actions?
- Yes — pass the compressed File as you would the original.
Pour les développeurs
Intégrez la compression dans votre flux d’envoi :
npm install compresso.jsnpm · Docs