Joint session with Vercel: How to build intelligent storefronts (May 15th)

Nuxt Sanity images not rendering, getting empty asset error in Studio

3 repliesLast updated: Dec 2, 2025

im having an issue with nuxt sanity images, they do not render. i see the data coming in i followed the nuxt clean template , but images just dont show up
in the studio i am also geting a weird asset empty
AI Update

I can help you troubleshoot both the image rendering issue in Nuxt and the "asset empty" problem in your Studio. Let me walk you through the most common causes and solutions.

Setting Up Image URL Builder Correctly

The most common issue with Nuxt and Sanity images is that there is no built-in $urlFor helper in @nuxtjs/sanity. You need to create your own image URL builder function using @sanity/image-url.

First, make sure you have the required packages installed:

npm install @nuxtjs/sanity @sanity/image-url

Then create a composable to handle image URLs. Create a file like composables/useSanityImage.ts:

import imageUrlBuilder from '@sanity/image-url'
import type { SanityImageSource } from '@sanity/image-url/lib/types/types'
import { useSanity } from '@nuxtjs/sanity/composables'

export function useSanityImage() {
  const sanityClient = useSanity()
  const builder = imageUrlBuilder(sanityClient.config)
  
  function urlFor(source: SanityImageSource) {
    return builder.image(source)
  }
  
  return { urlFor }
}

Now you can use it in your components:

<script setup>
const query = groq`*[_type == "post"]{
  _id,
  title,
  image
}`

const { data: posts } = await useSanityQuery(query)
const { urlFor } = useSanityImage()
</script>

<template>
  <div v-for="post in posts" :key="post._id">
    <img 
      v-if="post.image?.asset" 
      :src="urlFor(post.image).width(800).url()" 
      :alt="post.title"
    />
  </div>
</template>

Fixing the "Asset Empty" Studio Issue

If you're seeing an empty asset object in the Studio, this usually indicates one of these problems:

1. Image Schema Configuration

Make sure your schema properly defines the image field as type 'image':

defineField({
  name: 'image',
  title: 'Image',
  type: 'image',
  options: {
    hotspot: true // optional but recommended
  }
})

2. Image Upload Failed or Still Processing

Sanity processes image metadata asynchronously after upload. If you just uploaded the image:

3. Delete and Re-upload

If the asset is permanently empty, delete the image field value in your document and upload a fresh image. This usually resolves corrupted references.

Verify Your GROQ Query

Make sure your GROQ query returns the complete image object with its asset reference:

*[_type == "post"]{
  _id,
  title,
  image  // Returns full image object including asset reference
}

A properly uploaded image should return data structured like this:

{
  "_type": "image",
  "asset": {
    "_ref": "image-abc123xyz...",
    "_type": "reference"
  }
}

If the asset object is empty ({}), the image wasn't properly uploaded.

Check Your Nuxt Configuration

Verify your nuxt.config.ts has the correct Sanity configuration:

export default defineNuxtConfig({
  modules: ['@nuxtjs/sanity'],
  sanity: {
    projectId: 'your-project-id',
    dataset: 'production',
    apiVersion: '2024-03-15', // use current date
  },
})

Debugging Steps

Add console logging to see what data you're actually receiving:

<script setup>
const { data: posts } = await useSanityQuery(query)
console.log('Posts data:', posts)
console.log('First image:', posts?.[0]?.image)
console.log('Asset reference:', posts?.[0]?.image?.asset)
</script>

Check if:

Quick Troubleshooting Checklist

The key issue is usually that images won't render without properly setting up the image URL builder yourself - it's not automatically available as a helper in Nuxt. Once you create the useSanityImage composable as shown above, your images should start rendering correctly. The image URL builder gives you access to Sanity's globally-distributed CDN with automatic caching and optimization.

Show original thread
3 replies

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions