[**@wocart/theme v4.1.0**](../../README)

***

[@wocart/theme](../../README) / [index](../README) / createInstance

# Function: createInstance()

> **createInstance**(`definition`, `id`, `props?`): [`ComponentInstance`](../interfaces/ComponentInstance)

Create a new instance with insertion-time defaults:
materialises `field.default` values only — content-keyed fields stay unset
until a merchant overrides them. Throws on programmer errors (empty id,
unknown keys, wrong-typed values, a required field with nothing to fill
it); the storefront never calls this. A required field with a `contentKey`
is filled from the content pack at render, so it may be left unset here.

Authored defaults are validated exactly like provided values: a default that
fails its field's rules (out-of-range number, off-list select option) is an
authoring bug, and `validateThemeDefinition` reports it at assembly time —
baking it into an instance silently here would let the writer and the reader
disagree.

## Parameters

### definition

[`ComponentDefinition`](../interfaces/ComponentDefinition)

### id

`string`

### props?

[`JsonObject`](../type-aliases/JsonObject)

## Returns

[`ComponentInstance`](../interfaces/ComponentInstance)
