---
schema_version: "1"
id: 23b27ffd80812542ba7e69955a0d33e87cf13a977d08d8b1d80d1872f305b3ef
title: createComponent()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/aura-platform/guides/aura/ref-jsapi/ref-jsapi-dollara-createcomponent.md
canonical_url: https://developer.salesforce.com/docs/platform/aura-platform/guide/ref-jsapi-dollara-createcomponent.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0e6fdaa3b4d38f3c9c976fe010d1940b677a1ce2a05ae0531099ffc091532974
products:
  - Lightning Aura Components Developer Guide
  - Platform Developer Content
---

# createComponent()

Create a component from a type and a set of attributes. This method accepts the name of a type of component, a map of attributes, and a callback to notify the caller.

## Signature

`createComponent(String type, Object attributes, function callback)`

## Parameters

**_type_:** Type: `String`. The type of component to create. For example, `"lightning:button"`.

**_attributes_:** Type: `Object`. A map of attributes to send to the component. These attributes take the same form as in the markup, including events `{"press":component.getReference("c.handlePress")}`, and id `{"aura:id":"myComponentId"}`.

**_callback(cmp, status, errorMessage)_:** Type: `function`. The callback to invoke after the component is created. The callback has three parameters.

1.  `cmp`—The component that was created. This parameter enables you to do something with the new component, such as add it to the body of the component that creates it. If there’s an error, `cmp` is `null`.
2.  `status`—The status of the call. The possible values are `SUCCESS`, `INCOMPLETE`, or `ERROR`. Always check that the status is `SUCCESS` before you try to use the component.
3.  `errorMessage`—The error message if the status is `ERROR`.

**See Also**  


-   [Dynamically Creating Components](https://developer.salesforce.com/docs/platform/aura-platform/js-cb/js-cb-dynamic-cmp-async.md)

