---
title: "getRandomUUID"
description: "Generate a random RFC 4122 version 4 UUID string, using the platform crypto API for collision-resistant unique identifiers."
canonical_url: "https://core.mhaibaraai.cn/en/docs/helpers/uuid"
---
# getRandomUUID

> Generate a random RFC 4122 version 4 UUID string, using the platform crypto API for collision-resistant unique identifiers.

## Usage

`getRandomUUID` generates a random string in UUID v4 format.

```ts
import { getRandomUUID } from '@movk/core'

const id1 = getRandomUUID()
console.log(id1) // 'f47ac10b-58cc-4372-a567-0e02b2c3d479'

const id2 = getRandomUUID()
console.log(id2) // 'f47ac10b-58cc-4372-a567-0e02b2c3d480'

// Use to generate unique identifiers
const componentId = `component-${getRandomUUID()}`
```

## API

### `getRandomUUID()`

Generate a random UUID string.

### Returns

**returns** (`string`): A random string in UUID v4 format.

## Changelog

See commit history for [src/helpers/getRandomUUID.ts](https://github.com/mhaibaraai/movk-core/commits/main/src/helpers/getRandomUUID.ts).

---

- [GitHub](https://github.com/mhaibaraai/movk-core/blob/main/src/helpers/uuid.ts)


## Sitemap

See the full [sitemap](https://core.mhaibaraai.cn/sitemap.md) for all pages.
