Skip to main content
Learn how to effectively use images in your Kleap app. Kleap builds Astro static sites, so images use standard web patterns — files in your public/ folder, Astro’s optimized <Image /> component, or plain <img> tags. There’s no image build configuration to set up.

Adding Images

From URL

Use any public image URL:
External images work with a normal <img> tag — no allowlist or domain configuration required.

Uploading Images

Upload images directly in Kleap and the AI will place them for you:
Uploaded images are hosted by Kleap and stored in your app’s public/ folder, accessible at /image-name.jpg.

Generate Images with AI

Kleap can generate images for you with AI — free, no credits used:
Great for hero backgrounds, illustrations, and placeholders when you don’t have your own photos yet.

Astro Image Component

For images you ship with your site, use Astro’s built-in <Image /> component from astro:assets. Put the source in src/assets/ and import it:

Benefits

  • Automatic optimization - Converts to WebP/AVIF
  • Lazy loading - loading="lazy" by default
  • Correct sizing - Serves an appropriately sized image
  • No layout shift - Requires width/height, which prevents CLS

Plain img tags

For images in public/ (including uploaded and AI-generated ones), a normal <img> works too — just add width, height, and loading="lazy":
For a hero image (usually your largest, above-the-fold visual), load it eagerly so it appears fast:

Ask AI to Optimize

Image Best Practices

File Formats

FormatBest For
WebPPhotos, general use
PNGLogos, icons, transparency
SVGIcons, illustrations
AVIFBest compression (newer)

File Sizes

Keep images optimized:
  • Hero images: < 200KB
  • Content images: < 100KB
  • Thumbnails: < 30KB

Dimensions

Provide images at appropriate sizes. For responsive images, tell the browser which size to load with the widths and sizes props:

Responsive Images

Cover a Container

To fill a container while keeping aspect ratio, size the wrapper and use object-cover:

Responsive Sizes

Tell the browser what size to load:

External Images

For images hosted elsewhere (Unsplash, a CDN, your own server), just reference the URL with a plain <img>:
No domain allowlist or config is needed — Astro sites serve external image URLs directly. Popular sources include:
  • images.unsplash.com
  • cdn.pixabay.com
  • res.cloudinary.com

Uploaded & Generated Images

Most images on a Kleap site are static assets — files you upload in Kleap or generate with AI. These are hosted by Kleap in your public/ folder, so you reference them like any local image:
If you need to accept image uploads from your own visitors at runtime, store them in Kleap Database and render them from the stored URL. For most sites, static uploaded or AI-generated assets are all you need.

Background Images

CSS Background

For decorative backgrounds:

With Overlay

Icons

Lucide Icons

Kleap uses Lucide icons via lucide-react, rendered inside React islands:

SVG Icons

For custom icons:

Alt Text Guidelines

Always provide descriptive alt text:

When to Use Empty Alt

Decorative images that don’t convey information:

Common Image Patterns

Hero with Image

Avatar

Troubleshooting

  • Check the file path is correct
  • Verify the image exists in the public folder
  • For external images, confirm the URL is public and reachable
  • Provide a higher resolution source image
  • Check width/height props match the aspect ratio
  • Prefer Astro’s <Image /> so the right size is served
  • Always specify width and height
  • Use Astro’s <Image />, which reserves space automatically
  • Wrap in a sized container for cover/fill layouts

Using Videos

Learn how to embed videos in your app