How AI is powering better personalization in e-commerce [with Vercel]. Sign up now

Using tel: protocol with dynamic phone numbers in mapped array from Sanity

9 repliesLast updated: Nov 29, 2025

Hey all, I'm having trouble figuring out the syntax needed for this. I need to use the <a href="tel:"> protocol to pull in the relevant numbers within a map method, so the code looks a bit like this:

{array.map((item) => {
   <a href="tel:{item.phone}">Call Person</a>
})}
This is pulling in data using GraphQL from Sanity.
AI Update

This is a JSX templating syntax issue. You need to use template literals or string concatenation to properly interpolate the phone number variable.

Change this:

<a href="tel:{item.phone}">Call Person</a>

To this:

<a href={`tel:${item.phone}`}>Call Person</a>

Your complete map should look like:

{array.map((item) => (
  <a key={item._id} href={`tel:${item.phone}`}>Call Person</a>
))}

The key points:

Since you're pulling data from Sanity via GraphQL, just make sure your phone field is included in your GraphQL query and the data structure matches what you're accessing.

Show original thread
9 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