From d84c1c14676378f51857097c44cea9d39ab2433f Mon Sep 17 00:00:00 2001 From: "Amir H. Hashemi" <87268103+amirhhashemi@users.noreply.github.com> Date: Thu, 13 Nov 2025 11:17:10 +0330 Subject: [PATCH 1/4] Update createUniqueId reference --- .../component-apis/create-unique-id.mdx | 49 ++++++++++++++++--- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/src/routes/reference/component-apis/create-unique-id.mdx b/src/routes/reference/component-apis/create-unique-id.mdx index 82c1c88e0..5ea8eb720 100644 --- a/src/routes/reference/component-apis/create-unique-id.mdx +++ b/src/routes/reference/component-apis/create-unique-id.mdx @@ -9,23 +9,58 @@ tags: - ssr - forms - utilities -version: '1.0' +version: "1.0" description: >- Generate unique IDs that are stable across server and client with createUniqueId. Essential for accessible forms and SSR-compatible components. --- -```ts -import { createUniqueId } from "solid-js" +The `createUniqueId` function generates a unique ID that remains consistent across both server and client renders. + +This function is commonly used for HTML `id` and `for` attributes to ensure stable hydration. + +It is important to note that `createUniqueId` does not generate a cryptographically secure ID and is not suitable for security-sensitive data. +Additionally, it is not appropriate for scenarios that require uniqueness across a distributed system. + +:::note +`createUniqueId` relies on a counter-based mechanism to generate IDs. +It must be called the same number of times on both the server and client. -function createUniqueId(): string +Calling `createUniqueId` only on the server or only on the client—such as when using [`isServer`](/reference/rendering/is-server) or [``](/reference/components/no-hydration)—may lead to hydration errors. +::: +## Import + +```ts +import { createUniqueId } from "solid-js"; ``` -A universal id generator that is stable across server/browser. +## Type ```ts -const id = createUniqueId() +function createUniqueId(): string; ``` -**Note:** on the server this only works under hydratable components. +## Parameters + +This function does not take any parameters. + +## Returns + +`createUniqueId` returns a unique `string` that is stable across server and client renders. + +## Examples + +### Basic Usage + +```tsx +import { createUniqueId } from "solid-js"; + +type InputProps = { + id?: string; +}; + +function Input(props: InputProps) { + return ; +} +``` From 865e52645363c5fbdd5502b80ace9b4d972b8967 Mon Sep 17 00:00:00 2001 From: Amir Hossein Hashemi <87268103+amirhhashemi@users.noreply.github.com> Date: Wed, 19 Nov 2025 07:22:14 +0330 Subject: [PATCH 2/4] Update src/routes/reference/component-apis/create-unique-id.mdx Co-authored-by: Sarah --- src/routes/reference/component-apis/create-unique-id.mdx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/routes/reference/component-apis/create-unique-id.mdx b/src/routes/reference/component-apis/create-unique-id.mdx index 5ea8eb720..e7c28c440 100644 --- a/src/routes/reference/component-apis/create-unique-id.mdx +++ b/src/routes/reference/component-apis/create-unique-id.mdx @@ -16,8 +16,7 @@ description: >- --- The `createUniqueId` function generates a unique ID that remains consistent across both server and client renders. - -This function is commonly used for HTML `id` and `for` attributes to ensure stable hydration. +It is commonly used with HTML `id` and `for` attributes to ensure stable hydration. It is important to note that `createUniqueId` does not generate a cryptographically secure ID and is not suitable for security-sensitive data. Additionally, it is not appropriate for scenarios that require uniqueness across a distributed system. From 4130564dce598b735012fb05966798528cd518d3 Mon Sep 17 00:00:00 2001 From: Amir Hossein Hashemi <87268103+amirhhashemi@users.noreply.github.com> Date: Wed, 19 Nov 2025 07:23:26 +0330 Subject: [PATCH 3/4] Update src/routes/reference/component-apis/create-unique-id.mdx Co-authored-by: Sarah --- src/routes/reference/component-apis/create-unique-id.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/reference/component-apis/create-unique-id.mdx b/src/routes/reference/component-apis/create-unique-id.mdx index e7c28c440..ab944f622 100644 --- a/src/routes/reference/component-apis/create-unique-id.mdx +++ b/src/routes/reference/component-apis/create-unique-id.mdx @@ -25,7 +25,7 @@ Additionally, it is not appropriate for scenarios that require uniqueness across `createUniqueId` relies on a counter-based mechanism to generate IDs. It must be called the same number of times on both the server and client. -Calling `createUniqueId` only on the server or only on the client—such as when using [`isServer`](/reference/rendering/is-server) or [``](/reference/components/no-hydration)—may lead to hydration errors. +Calling `createUniqueId` only on the server or only on the client, such as when using [`isServer`](/reference/rendering/is-server) or [``](/reference/components/no-hydration), may lead to hydration errors. ::: ## Import From 5cde999684ddc25ae553881aebfc662e39e5048d Mon Sep 17 00:00:00 2001 From: Amir Hossein Hashemi <87268103+amirhhashemi@users.noreply.github.com> Date: Wed, 19 Nov 2025 08:00:43 +0330 Subject: [PATCH 4/4] Update src/routes/reference/component-apis/create-unique-id.mdx Co-authored-by: Sarah --- src/routes/reference/component-apis/create-unique-id.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/reference/component-apis/create-unique-id.mdx b/src/routes/reference/component-apis/create-unique-id.mdx index ab944f622..ea3f4f503 100644 --- a/src/routes/reference/component-apis/create-unique-id.mdx +++ b/src/routes/reference/component-apis/create-unique-id.mdx @@ -18,8 +18,8 @@ description: >- The `createUniqueId` function generates a unique ID that remains consistent across both server and client renders. It is commonly used with HTML `id` and `for` attributes to ensure stable hydration. -It is important to note that `createUniqueId` does not generate a cryptographically secure ID and is not suitable for security-sensitive data. -Additionally, it is not appropriate for scenarios that require uniqueness across a distributed system. +`createUniqueId` does *not* generate a cryptographically secure ID and is not suitable for security-sensitive data. +Additionally, it should not be used in scenarios that require uniqueness across a distributed system. :::note `createUniqueId` relies on a counter-based mechanism to generate IDs.