# Issue with SSR Hooks in Slices

**URL:** <https://community.prismic.io/t/issue-with-ssr-hooks-in-slices/9642>\
**Category:** Developing with Prismic\
**Tags:** nextjs, typescript\
**Created:** [April 4, 2022, 9:19pm UTC](https://community.prismic.io/t/issue-with-ssr-hooks-in-slices/9642 "2022-04-04T21:19:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanne.v1stra](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/sanne.v1stra/32/4276_2.png) [@sanne.v1stra](https://community.prismic.io/u/sanne.v1stra)\
**Post date:** [April 4, 2022, 9:19pm UTC](https://community.prismic.io/t/issue-with-ssr-hooks-in-slices/9642/1 "2022-04-04T21:19:20Z")

</div>

Hi Prismic Community,

Since I've been working with slices I've found out that one of the 'struggles' is getting relational data inside a slice. Since the 'content relation' field can have more than 1 'custom type' its hard to define ALL the fields in there to load extra. So what i've done is sending the whole data to a new component and use a prismic hook to get the data. (Quite inefficient if you have to say so)

Though, because of this I'm getting the following error:

```auto
 Error: Invariant failed: A @prismicio/client is required to query documents. Provide a client to the hook or to a <PrismicProvider> higher in your 
component tree.

```

I've got a PrismicProvider in the app.tsx. I've installed the whole repo fresh with slicemachine. Can't find the credentials it logged in with (Where they are stored or something).

The code I've got right now:

```auto
import {usePrismicDocumentByUID} from "@prismicio/react";
import * as prismicT from "@prismicio/types";

const TeamMember = ({data, variant}: {data: prismicT.RelationField, variant?: string}) => {
    const [page] = usePrismicDocumentByUID(data.type, data.uid);

    return (
        <div className={style.wrapper}>
            <h2>{page.name}</h2>
        </div>
    );
}

export default TeamMember;

```

I've got 2 questions;

1. How can I get the SSR Hook to work?
2. Is there another solution so I dont have to actually use the ssr hook at all and can load the data via a \* mark somewhere?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [April 7, 2022, 11:15am UTC](https://community.prismic.io/t/issue-with-ssr-hooks-in-slices/9642/3 "2022-04-07T11:15:04Z")

</div>

Hello @sanne.v1stra

Thanks for reaching out to us.

It's difficult for me to answer without having complete source code. Can you share more details?

Thanks,  
Priyanka

---

<div class="post-metadata">

**Author:** ![sanne.v1stra](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/sanne.v1stra/32/4276_2.png) [@sanne.v1stra](https://community.prismic.io/u/sanne.v1stra)\
**Post date:** [April 12, 2022, 6:35pm UTC](https://community.prismic.io/t/issue-with-ssr-hooks-in-slices/9642/4 "2022-04-12T18:35:45Z")

</div>

Hi @Priyanka,

I've done some recoding and the SSR hooks are working as they should be.  
Sorry for the late update. (Havent been able to touch code for a few days)

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [April 13, 2022, 8:48am UTC](https://community.prismic.io/t/issue-with-ssr-hooks-in-slices/9642/5 "2022-04-13T08:48:18Z")

</div>

Thanks, @sanne.v1stra, for the update. Feel free to reach out to us if you have any questions.
