Framework examples

Placeholder images in React, Next.js, Vue, Angular and Tailwind

A DummyImg URL is a normal image URL, so it works in every framework. These examples show the idiomatic way to use one in each, plus the one config change Next.js needs.

Open the generator
Dark 800 x 450 placeholder image labelled React, Vue, Angular
800 x 450 example from DummyImg

URLs used in these examples

Card image, 400 x 300

https://www.dummyimg.in/placeholder?width=400&height=300

Hero banner, 1200 x 400

https://www.dummyimg.in/placeholder?width=1200&height=400&text=Hero

Avatar, 96 x 96

https://www.dummyimg.in/placeholder?width=96&height=96&text=JD&bg_color=%23245bd8&text_color=%23ffffff

Lightweight SVG, 640 x 360

https://www.dummyimg.in/placeholder?width=640&height=360&format=SVG

Examples by framework

Always set width and height on the image element as well as in the URL. The browser then reserves the space before the image loads, so the layout doesn't jump (no cumulative layout shift).

For many small placeholders, format=SVG gives the smallest files. For screenshots and social previews, use PNG or WEBP.

React
function ProductCard({ name }) {
  return (
    <img
      src="https://www.dummyimg.in/placeholder?width=400&height=300&text=Product"
      width={400} height={300} alt={name}
    />
  );
}
Next.js (next/image)
// next.config.js
module.exports = {
  images: {
    remotePatterns: [{ protocol: "https", hostname: "www.dummyimg.in" }],
  },
};

// page.jsx
import Image from "next/image";
<Image src="https://www.dummyimg.in/placeholder?width=400&height=300" width={400} height={300} alt="" />
Vue
<template>
  <img :src="url" :width="w" :height="h" alt="Placeholder" />
</template>

<script setup>
const w = 400, h = 300;
const url = `https://www.dummyimg.in/placeholder?width=${w}&height=${h}`;
</script>
Angular (NgOptimizedImage)
<img
  ngSrc="https://www.dummyimg.in/placeholder?width=400&height=300"
  width="400" height="300" alt="Placeholder"
/>
Svelte
<script>
  export let w = 400, h = 300;
</script>

<img src={`https://www.dummyimg.in/placeholder?width=${w}&height=${h}`} width={w} height={h} alt="" />
Tailwind CSS
<div class="h-64 bg-cover bg-center
  bg-[url('https://www.dummyimg.in/placeholder?width=1200&height=400&text=Hero')]">
</div>

Questions

Why does Next.js say the hostname is not configured?

next/image only loads remote images from hosts you allow. Add www.dummyimg.in to images.remotePatterns in next.config.js, as in the example above, then restart the dev server.

Can I use SVG placeholders with next/image?

next/image blocks remote SVG by default. Either use format=PNG or WEBP, or set images.dangerouslyAllowSVG in next.config.js if you understand the trade-off.

Do the images work with server-side rendering?

Yes. The URL is plain text, so it renders the same on the server and in the browser.

Can I fetch images from JavaScript in the browser?

Yes. The /placeholder and /download endpoints send CORS headers, so fetch() works from any origin.

More dummy image guides