
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThe issue is that you need to dereference the asset properly in your GROQ query. The syntax you're using is close, but it needs a slight adjustment.
Your current query:
PDF{
asset->url
}This should actually be:
"pdf": PDF.asset->urlOr if you want to keep the entire PDF object structure and add the URL:
PDF{
...,
"url": asset->url
}The key is using dot notation (PDF.asset->) rather than just querying inside the object. The -> operator dereferences the asset reference to get the actual asset document, and then you access its url property.
So your full query might look something like:
*[_type == "yourDocumentType"]{
"pdfUrl": PDF.asset->url
}Then in your component, you can use it directly:
<a href={pdfUrl}>Download PDF</a>Bonus tip: If you want the file to trigger a download instead of opening in the browser, append ?dl to the URL:
<a href={`${pdfUrl}?dl`}>Download PDF</a>This works because Sanity's asset URLs support the ?dl query parameter to force downloads, which is especially useful since the standard HTML download attribute doesn't work across different origins.
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store