> ## Documentation Index
> Fetch the complete documentation index at: https://docs.beyondwords.io/llms.txt
> Use this file to discover all available pages before exploring further.

# New Event

> Utility for creating well-formed player event payloads.

Stamps the common fields (`id`, `createdAt`, `status`, `initiatedBy`) onto a
player event payload so every event you emit is well-formed. It's plain JS,
identical across frameworks.

## Installation

<CodeGroup>
  ```bash npm theme={null}
  npx @beyondwords/cli components add new-event --html
  ```

  ```bash pnpm theme={null}
  pnpm dlx @beyondwords/cli components add new-event --html
  ```

  ```bash yarn theme={null}
  yarn dlx @beyondwords/cli components add new-event --html
  ```

  ```bash bun theme={null}
  bunx --bun @beyondwords/cli components add new-event --html
  ```
</CodeGroup>

## Usage

```js theme={null}
import { newEvent } from "@/lib/newEvent";

player.onEvent(
  newEvent({
    type: "PressedPlay",
    description: "The play button was pressed.",
  }),
);
// => { id, createdAt, status: 'pending', initiatedBy: 'user', type, description }
```
