# Add Privacy Policy Field/Slice

**URL:** <https://community.prismic.io/t/add-privacy-policy-field-slice/14839>\
**Category:** Developing with Prismic\
**Tags:** typescript, slice-machine, nextjs\
**Created:** [December 26, 2023, 4:39pm UTC](https://community.prismic.io/t/add-privacy-policy-field-slice/14839 "2023-12-26T16:39:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![akbarbakhshiwebdev](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@akbarbakhshiwebdev](https://community.prismic.io/u/akbarbakhshiwebdev)\
**Post date:** [December 26, 2023, 4:39pm UTC](https://community.prismic.io/t/add-privacy-policy-field-slice/14839/1 "2023-12-26T16:39:52Z")

</div>

Hello. I am integrating Prismic into my NextJS project and am trying to make a field or a slice for HTML content that I get from my privacy policy generator.

Basically, I have this HTML code that I can get from my privacy policy generator tool so that I can embed it on my website. I have referenced [this post](https://community.prismic.io/t/add-custom-embed-or-html-code/5455) to handle the case:

1. Created a Page type called "Privacy Policy"

2. Added a Rich Text field to the `Static Zone` (screenshot below).  

3. I copied the HTML code in the `policy_html` field.

4. I can see that the HTML can be retrieved as a string on the NextJS side, but I am not able to render it properly. This is a sample of the HTML code:

```auto
<h1 class="privacy-policy-h1">Privacy Policy
<br><span>Last Updated On 26-Dec-2023</span>
<br><span>Effective Date 26-Dec-2023</span>
</h1>

<p class="privacy-policy-p">
...
</p>
...

```

I cannot use `page.data.policy_html` as `innerHTML` for my div element since it is a `RichTextField`. I gave it a shot and tried the followings and neither worked (since I am getting a string back)

```auto
<PrismicRichText field={page.data.policy_html} />

```

```auto
 <PrismicRichText
  field={page.data.policy_html}
  components={{
    preformatted: ({ children }) => <pre>{children}</pre>,
  }}
/>

```

Any help would be very much appreciated 🙂

---

<div class="post-metadata">

**Author:** ![samlittlefair](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/samlittlefair/32/696_2.png) [@samlittlefair](https://community.prismic.io/u/samlittlefair)\
**Post date:** [December 27, 2023, 11:53am UTC](https://community.prismic.io/t/add-privacy-policy-field-slice/14839/2 "2023-12-27T11:53:29Z")

</div>

Hi Akbar,

We don't recommend handling HTML in Prismic. This can introduce usability and stability issues. Nonetheless, I can tell you how to make this work if it is the only option for your use case.

You'll need to use the `asText` help from `@prismicio/client`.

```auto
import * as prismic from "@prismicio/client"

function MyComponent() {
  return <div dangerouslySetInnerHTML={prismic.asText(page.data.policy_html)} />;
}

```

`asText()` will render your rich text field as plain text (HTML code) and `dangerouslySetInnerHTML` will inject the HTML into your component.

Sam

---

<div class="post-metadata">

**Author:** ![akbarbakhshiwebdev](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@akbarbakhshiwebdev](https://community.prismic.io/u/akbarbakhshiwebdev)\
**Post date:** [December 27, 2023, 3:17pm UTC](https://community.prismic.io/t/add-privacy-policy-field-slice/14839/3 "2023-12-27T15:17:20Z")

</div>

Hi Sam,  
Thanks for the response. Your code worked (almost) perfectly. I just needed to modify it a little bit to stop typescript screaming at me:

```auto
<div dangerouslySetInnerHTML={{__html: prismic.asText(page.data.policy_html)}} />

```

On a relevant note, what would be the recommended way (or how would you recommend) to include a Privacy Policy on a website using Prismic since you warned me about using HTML in Prismic?

Thanks again for the help.

---

<div class="post-metadata">

**Author:** ![samlittlefair](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/samlittlefair/32/696_2.png) [@samlittlefair](https://community.prismic.io/u/samlittlefair)\
**Post date:** [December 28, 2023, 10:58am UTC](https://community.prismic.io/t/add-privacy-policy-field-slice/14839/4 "2023-12-28T10:58:44Z")

</div>

Hey Akbar,

Normally, we would recommend that a user create a Privacy Policy document using a standard rich text field. Rather than inputting HTML, you could input rich text and template it using `<PrismicRichText>`. Why are you using HTML in this case?

Sam

---

<div class="post-metadata">

**Author:** ![akbarbakhshiwebdev](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@akbarbakhshiwebdev](https://community.prismic.io/u/akbarbakhshiwebdev)\
**Post date:** [December 28, 2023, 3:17pm UTC](https://community.prismic.io/t/add-privacy-policy-field-slice/14839/5 "2023-12-28T15:17:18Z")

</div>

Hey Sam,  
Just because the privacy policy generator tool ([termly.io](http://termly.io) or similar platforms) that I use normally give me the HTML code for it. I thought that is easier to copy and paste into a `pre` tag, but now that you mentioned using RichText, I suppose that is also possible. I can just copy the formatted text directly from the tool and paste into the Rich Text editor and it preserves the links, tags, etc.

Thanks for the help again 🙂

---

<div class="post-metadata">

**Author:** ![samlittlefair](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/samlittlefair/32/696_2.png) [@samlittlefair](https://community.prismic.io/u/samlittlefair)\
**Post date:** [December 29, 2023, 9:55am UTC](https://community.prismic.io/t/add-privacy-policy-field-slice/14839/6 "2023-12-29T09:55:50Z")

</div>

Glad that helped!
