---
title: "Custom HTML Module for Sanity + Next.js"
description: "Drop raw HTML, CSS, and JS into any page with the Custom HTML module for full styling control without leaving Sanity Studio."
---

# Custom HTML module

Write raw HTML and CSS right in Sanity Studio. Script tags run on the client, so you can embed widgets, third-party scripts, or interactive visuals. It's also available as a block inside other modules' rich text.

[View source on GitHub](https://github.com/nuotsu/sanitypress/tree/main/src/modules/custom-html) (schema + React component)

## Module fields

| Field | Type | Description |
| --- | --- | --- |
| `html` | code (HTML) | Markup to render. `<script>` tags are re-run on the client. |
| `css` | code (CSS) | Styles injected alongside the markup. |
| `className` | string | Class name for the root element, e.g. `section prose`. |
| `attributes` | `module-attributes` | Shared by every module: `uid` (HTML id for deep links), `hidden`, and `scopedCss`. |

## Demo: Inline script

Write custom HTML, JavaScript or CSS. Anything goes!

## Demo: Three.js globe

Loads three.js from a CDN as an ES module and plots recent site visitors on a draggable globe.

## Demo: X post embed

Frequently Asked Questions

## Custom HTML module FAQ

### When should I use the Custom HTML module?

Use it when no built-in module fits: embeds, one-off interactive widgets, animations, or a quick experiment you want on the page today without a code deploy. It is also a fast way to prototype a section before turning it into a proper module.

### How do I add the Custom HTML module to a page?

In Sanity Studio, open the page, click Add item in its Modules field, and pick Custom HTML. Fill in the fields, check it in the live Presentation preview, and publish. Modules can be reordered by dragging, and the same module can be used on any page as many times as you need.

### How do I customize the Custom HTML module?

Paste markup into the HTML field and styles into the CSS field, and optionally set a className for the root element, such as section prose.

Markup without scripts renders on the server. If the HTML includes a <script> tag, the whole block is injected and run in the browser after the page loads, so keep anything search engines need to read (copy, links, structured data) out of script-based blocks.

Every module also has a Scoped CSS field (plus a uid for deep links and a hidden toggle), so you can restyle one instance without touching the rest of the site. For bigger changes, edit the module's React component and schema in src/modules/custom-html in the repo.

Previous module

![Breadcrumbs module](https://cdn.sanity.io/images/cyu7k2r0/production/6ae52d92d2879c28331fb355a55f9fcec87e2066-2560x104.png)

[Breadcrumbs module](/modules/breadcrumbs)

Next module

![Blog post list module](https://cdn.sanity.io/images/cyu7k2r0/production/3c4a12acfd995d697a105959910099066188251d-2560x1136.png)

[Blog post list module](/modules/blog-post-list)
