Bolt storage

Image Compression and Optimization Not Working in Bolt App

Your Bolt.new application loads images at full resolution regardless of display size, causing slow page loads, excessive bandwidth usage, and poor Core Web Vitals scores. A 5MB profile photo is served at 4000x3000 pixels even though it's displayed at 100x100 on the page.

Bolt's AI typically generates basic img tags or stores images exactly as uploaded without any processing. This means a user uploading a 10MB DSLR photo gets that exact 10MB file served to every visitor, even on slow mobile connections.

The problem compounds quickly: a page with 20 user-uploaded images can require 50MB+ of downloads, making your app unusable on mobile and destroying your Google PageSpeed score. Image optimization is one of the biggest performance wins for any web application.

Error Messages You Might See

LCP (Largest Contentful Paint) exceeded 4 seconds Warning: Image with src has no width or height Error: sharp module not found in production net::ERR_CONTENT_LENGTH_MISMATCH (large image transfer failed)
LCP (Largest Contentful Paint) exceeded 4 secondsWarning: Image with src has no width or heightError: sharp module not found in productionnet::ERR_CONTENT_LENGTH_MISMATCH (large image transfer failed)

Common Causes

  • No image processing on upload — Images are stored at original resolution and format without server-side resizing or compression
  • Missing Next.js Image component — Using plain <img> tags instead of Next.js <Image> which provides automatic optimization
  • No lazy loading — All images load eagerly on page load, even those below the fold that aren't visible yet
  • Wrong image format — Serving PNG or JPEG instead of modern WebP or AVIF formats that are 30-50% smaller
  • No responsive sizing — Serving the same large image regardless of the user's screen size or viewport

How to Fix It

  1. Use Next.js Image component — Replace <img> with <Image> which auto-optimizes: <Image src={url} width={400} height={300} quality={80} />
  2. Compress on upload — Process images server-side before storage using sharp: sharp(buffer).resize(1200, 1200, { fit: 'inside' }).webp({ quality: 80 }).toBuffer()
  3. Use Supabase image transforms — Serve optimized images via transform URL: supabase.storage.from('images').getPublicUrl(path, { transform: { width: 400, quality: 80 } })
  4. Add lazy loading — Add loading="lazy" to images below the fold, or use the IntersectionObserver API for custom lazy loading
  5. Generate multiple sizes — Create thumbnail, medium, and full-size versions on upload and serve the appropriate one using srcset
  6. Set proper cache headers — Configure Cache-Control: public, max-age=31536000, immutable for static image assets

Real developers can help you.

legrab legrab I'll fill this later Rudra Bhikadiya Rudra Bhikadiya I build and fix web apps across Next.js, Node.js, and DBs. Comfortable jumping into messy code, broken APIs, and mysterious bugs. If your project works in theory but not in reality, I help close that gap. Costea Adrian Costea Adrian Embedded Engineer specilizing in perception systems. Latest project was a adas camera calibration system. Meïr Ankri Meïr Ankri Full-stack developer specializing in React / Next.js / Node.js with 6+ years of experience. I've worked across various sectors including automotive (Reezocar/Société Générale), healthcare (Medical Link SaaS), and e-commerce (Glasman). I build web apps end-to-end, from architecture to production, with a focus on scalability, performance, and code quality. I also mentor junior developers and contribute to technical decisions and code reviews. Prakash Prajapati Prakash Prajapati I’m a Senior Python Developer specializing in building secure, scalable, and highly available systems. I work primarily with Python, Django, FastAPI, Docker, PostgreSQL, and modern AI tooling such as PydanticAI, focusing on clean architecture, strong design principles, and reliable DevOps practices. I enjoy solving complex engineering problems and designing systems that are maintainable, resilient, and built to scale. Caio Rodrigues Caio Rodrigues I'm a full-stack developer focused on building practical and scalable web applications. My main experience is with **React, TypeScript, and modern frontend architectures**, where I prioritize clean code, component reusability, and maintainable project structures. I have strong experience working with **dynamic forms, state management (Redux / React Hook Form), and complex data-driven interfaces**. I enjoy solving real-world problems by turning ideas into reliable software that companies can actually use in their daily operations. Beyond coding, I care about **software quality and architecture**, following best practices for componentization, code organization, and performance optimization. I'm also comfortable working across the stack when needed, integrating APIs, handling business logic, and helping transform prototypes into production-ready systems. My goal is always to deliver solutions that are **simple, efficient, and genuinely useful for the people using them.** Pratik Pratik SWE with 15+ years of experience building and maintaining web apps and extensive BE infrastructure Jacek Rozanski Jacek Rozanski Senior PHP/Symfony developer and DevOps engineer with 20+ years of professional experience, running opcode.pl (web development agency, est. 2004). Day job: I'm the sole backend developer at merketing company where I own and maintain 11 PHP/Symfony microservices on AWS (ECS Fargate, RDS, S3, CloudFront), handle the full CI/CD pipeline (Bitbucket Pipelines, Docker), and manage monitoring with Sentry and CloudWatch. These services handle high request volumes in production every month. What I bring to AI-built apps: - I audit and fix security issues (OWASP methodology), performance bottlenecks, and architectural problems in codebases generated by Cursor, Claude Code, Lovable, Bolt, and v0 - I refactor AI-generated prototypes into production-grade applications with proper error handling, testing, and clean architecture (SOLID, DDD, hexagonal architecture) - I set up the infrastructure AI tools don't touch: AWS hosting, CI/CD pipelines, automated deployments, database optimization, monitoring, and alerting - I integrate external services: payment providers, email systems, partner APIs, SSO/auth Tech stack: PHP 8.x, Symfony, React, Next.js, PostgreSQL, MySQL, Docker, AWS (ECS, RDS, S3, SQS/SNS, CloudFront), Terraform, Supabase. I also use AI tools daily (Claude Code, Cursor) in my own workflow, so I understand both the strengths and the gaps in AI-generated code. Based in Poland (CET timezone). Available for async work and calls during EU/US business hours. PawelPloszaj PawelPloszaj I'm fronted developer with 10+ years of experience with big projects. I have small backend background too Richard McSorley Richard McSorley Full-Stack Software Engineer with 8+ years building high-performance applications for enterprise clients. Shipped production systems at Walmart (4,000+ stores), Cigna (20M+ users), and Arkansas Blue Cross. 5 patents in retail/supply chain tech. Currently focused on AI integrations, automation tools, and TypeScript-first architectures.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

What image format should I use for web?

Use WebP as the default format - it provides 30% smaller files than JPEG at the same quality. For maximum compression, use AVIF (50% smaller than JPEG). Always provide a JPEG fallback for older browsers using the picture element.

How do I optimize images already in my storage bucket?

Use Supabase's built-in image transformation API to serve optimized versions without re-uploading. Add transform parameters to your getPublicUrl call: { transform: { width: 800, format: 'webp', quality: 75 } }.

Related Bolt Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help