# ThreadRoutingAdapter

Package: `@threadplane/react/chat` · 0.0.0

**Unpublished development API.**

Reference: /docs/api/react/chat/ThreadRoutingAdapter

```typescript
import type { ThreadRoutingAdapter } from '@threadplane/react/chat';
```

## ThreadRoutingAdapter

Binds the active thread to a URL. The default adapter uses `window.location` and
`window.history`; React Router or Next.js applications can supply one built from
their own location and navigation functions.

```typescript
export interface ThreadRoutingAdapter  {
  read(): string | null;
  subscribe(onChange: () => void): () => void;
  write(threadId: string | null, mode: ThreadRoutingWriteMode): void;
}
```

### read · overload 1

The thread id in the current URL, or null for the bare URL.

```typescript
read(): string | null;
```

### subscribe · overload 1

Call `onChange` when the URL changes outside `write`, such as back and forward.

```typescript
subscribe(onChange: () => void): () => void;
```

### write · overload 1

Write a thread id (null clears it) to the URL.

```typescript
write(threadId: string | null, mode: ThreadRoutingWriteMode): void;
```