---
url: /api/kiln/functions/prefab.md
---
[Kiln API](../../index.md) / [kiln](../index.md) / prefab

# Function: prefab()

```ts
function prefab<P>(build): Prefab<P>;
```

Defines a prefab:
`export const Enemy = prefab((p: { at: Vec3 }) => [Transform({ ...p.at }), Health({ hp: 30 })])`
then `commands.spawn(Enemy, { at })`.

## Type Parameters

| Type Parameter | Default type |
| ------ | ------ |
| `P` | `void` |

## Parameters

| Parameter | Type |
| ------ | ------ |
| `build` | (`params`) => `ConfigurableTrait`\[] |

## Returns

[`Prefab`](../interfaces/Prefab.md)<`P`>
