# sessionUuid

Make a UUIDv7 session ID for `config.session_id`.

The SDK requires UUIDv7 session IDs. `sessionUuid` encodes the current time in milliseconds in the first 48 bits and fills the rest from `crypto.getRandomValues`, so IDs sort by creation time. Store the ID to reopen the same session later.

```ts title="host.ts"
import { sessionUuid } from 'nanocode-wasm'

// For example 019a0b6e-3c1d-7a2f-9b4e-5d6c7e8f9a0b
const session_id = sessionUuid()
```

## Signature

```ts
// Reads Date.now() and crypto.getRandomValues
sessionUuid(): string
```

## Parameters

`sessionUuid` takes no parameters.

## Returns

* **Type:** `string`

A lowercase, hyphenated UUID with version 7 and the RFC 9562 variant.

```ts
import { sessionUuid } from 'nanocode-wasm'

// The version digit is 7
console.log(sessionUuid()[14])
```

## Errors

`sessionUuid` does not throw in a runtime that provides `crypto.getRandomValues`.

```ts
import { sessionUuid } from 'nanocode-wasm'

// Two calls return different IDs
console.log(sessionUuid() !== sessionUuid())
```
