A Next.js + Supabase image-optimization service that dynamically compresses and serves your images on the fly.
Live demo: supabase-onfly.vercel.app
- About
- Features
- Tech Stack
- Getting Started
- Usage
- Deployment
- Contributing
- Commits & Changelog
- License
- Contact
This project hooks into Supabase Storage and intercepts image requests to automatically optimize (resize/compress/format-convert) images at request time. Perfect for blogs, storefronts, or any site that needs on-the-fly image performance gains.
- Automatic resize, compression, WebP/AVIF conversion
- Caching with edge headers (via Vercel)
- Supabase Storage integration (S3-compatible)
- Zero-configuration for most use cases
- Extensible middleware for custom processing
- Next.js β Server-Side Rendering & API routes
- TypeScript β Static types
- Supabase β Storage & Auth
- Tailwind CSS β Utility-first styling
- Node.js β Server runtime
- Node.js β₯ 16
- A Supabase project (free tier works)
-
Clone the repo
git clone https://github.com/gambhirsharma/OnFly-Image-Optimization.git cd OnFly-Image-Optimization -
Install dependencies
npm install # or pnpm install -
Configure environment Create a Supabase project and add the API keys
Copy .env.example β .env.local and fill in your Supabase URL/Key:
NEXT_PUBLIC_SUPABASE_URL=your-supabase-url SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
npm run dev
# or
pnpm devOpen http://localhost:3000 to see it in action.
Once deployed, request any image via:
https://your-deploy-url/api/optimize?url=https://your-bucket.s3.supabase.co/path/to/image.jpg&width=800The middleware will:
- Fetch the original from Supabase Storage
- Resize & compress (using Sharp)
- Respond with optimized image + cache headers
For full API details, see API_REFERENCE.md
Hosted on Vercel (automatic GitHub integration)
Branch: main β auto-deploy on push
Current Deploy: https://supabase-onfly.vercel.app
Contributions are welcome! Please read below:
- Fork the project
- Create your feature branch (git checkout -b feat/YourFeature)
- Commit your changes (git commit -m 'feat: add amazing feature')
- Push to the branch (git push origin feat/YourFeature)
- Open a Pull Request
Check CONTRIBUTING.md for full guidelines on commit messages, code style, and issue templates.
We use Conventional Commits. See CHANGELOG.md for a full history.
Distributed under the MIT License. See LICENSE for details.
Created by Gambhir Sharma β feel free to reach out!
- Email: gambhir786191ss@gmail[dot]com
- Twitter: @gambhir_sharma
- Website: https://gambhir.dev
