Components & Context

createUniqueId

Returns a stable id string that matches between server-rendered and client-hydrated trees. Use it for <label for>, aria-labelledby, and other attributes that need consistent ids across SSR.


Import

import { createUniqueId } from "solid-js";

Type signature

function createUniqueId(): string;

Examples

function Field(props: { label: string }) {
const id = createUniqueId();
return (
<>
<label for={id}>{props.label}</label>
<input id={id} />
</>
);
}
Last updated: 7/4/26, 6:21 PMEdit this pageReport an issue with this page