Render data using fetchLinks

I'm trying to render data from a linked document in my Next.js project. From what I understand, I need to use FetchLinks but am unable to work out how to render the queried data in my template.

My Prismic data is below, where I am trying to pull in data from a document type called Person as the documents Author:

I think I've set up the function to reference the person data using fetchLinks but am unable to work out how to display the data in my template e.g. the person name

import React from 'react'

import DefaultLayout from 'layouts'
import { Header, SliceZone } from 'components'

import { queryRepeatableDocuments } from 'utils/queries'
import { RichText } from 'prismic-reactjs'

import { Client } from 'utils/prismicHelpers'

const Article = ({ doc, menu }) => {
  if (doc && {
    return (
        <div className="page">
          <Header menu={menu} />
          <div className="container my-12">
          <div className="container grid md:grid-cols-3">
            <div className="md:col-span-2">{RichText.render(}</div>
          <SliceZone sliceZone={} />

  // Call the standard error page if the document was not found
  return null;

export async function getStaticProps({ params, preview = null, previewData = {} }) {
  const { ref } = previewData

  const client = Client()

  const doc = await client.getByUID('opinion', params.uid, {'fetchLinks': ['person.uid', '']}, ref ? { ref, } : null) || {}
  const menu = await client.getSingle('menu', ref ? { ref } : null) || {}
  return {
    props: {

export async function getStaticPaths() {
  const documents = await queryRepeatableDocuments((doc) => doc.type === 'opinion')
  return {
    paths: => `/opinion/${doc.uid}`),
    fallback: true,

export default Article

Any help would be greatly appreciated.

Hi @mike1,

Thanks for posting, and welcome to the Prismic community! From a first look at your code, I'm not sure what the issue is. Could you let me know your repo name, so I can try to recreate the issue? (Feel free to send it in a DM if you like.)


Hey @samlittlefair,

Thanks for the welcome!

My issue is around RichText.render(} not rendering the name. I tried RichText.render(} but that threw an error. I get a Rich text argument should be an Array. Received undefined warning when I use, but no error.

I'll DM you the repo.


Hey @mike1,

Okay, looking more closely at this, in the screenshot of your API response, it looks like you're using GraphQL, but in the code snippet it looks like you're using the Rest API. If you're using the Rest API, fetchLinks should work fine, just as you have used it. But, if you're using GraphQl, you'll need to use deep fetching: Retrieve linked document content with the Prismic GraphQL API - Prismic

Let me know if that helps!


Hey @samlittlefair — the API response was just how I was looking at the data in API Browser — I'm not using GraphQL in this project.

Turns out I had to go one level deeper with my reference so instead of {RichText.render(} I needed {RichText.render(}

All sorted!

Great! Thanks for the update, @mike1 :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.