Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Bug: Template HTML element causes hydration issue #34835

Copy link
Copy link
@iankduffy

Description

@iankduffy
Issue body actions

When using server-side rendering, the template HTML seems to throw a hydration error. Not sure if it's related to how the browser processes template elements or how React is correcting the dom. I have tested this with Astro and Nextjs and have had the same error. The Template element is part of the HTML spec and should work https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template

Use case might be for shareable web components used in React.

Image

React version: React 19.1, 19.2

Steps To Reproduce

  1. Have a component which includes template element with elements inside.
  2. Render it server side and wait for hydration error should be triggered

Link to code example:

'use client';
export function Template() {
	return <template>hello</template>;
}
export default function Home() {
	return (
		<main>
			<section className='container mx-auto grid lg:grid-cols-4'>
				<div className='flex flex-col py-8 lg:col-span-3'>
					<Template />
				</div>
			</section>
		</main>
	);
}

The current behavior

Results in Error:

Error: Text content does not match server-rendered HTML.
See more info here: https://nextjs.org/docs/messages/react-hydration-error

Text content did not match. Server: "" Client: "hello"

The expected behavior

Template HTML element is a part of the HTML spec and should not cause hydration errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.