Data Collections Extension Files and Code

A data collections extension is available in Wix CLI apps and Wix-managed headless projects.

Note: A Studio Two site doesn't use this extension. A site creates collections directly instead. See Create a Collection in Studio Two.

When you add the extension, the generated files land under src/extensions/backend/data-collections/. One builder file registers every collection, and each collection has its own definition file:

Copy
FileWhat it's for
data-collections.extension.tsThe builder file that registers the project's collections. A project has one, shared by all its collections.
<collection-name>.tsThe definition of one collection, including its fields, permissions, indexes, and initial data.

<collection-name> comes from the name you give the collection. It must be 1 to 36 characters, using only letters, numbers, underscores, and hyphens, and it must be unique in the folder.

The extension is also registered in the project's src/extensions.ts, with an import and a .use() call. When you add more collections, their definition files go in the same folder, and the builder file imports them.

Builder file

The data-collections.extension.ts file calls extensions.dataCollections() with the collections to register. Import extensions from @wix/astro/builders, in both a Wix CLI app and a headless project:

Copy

This example registers two collections:

Copy

Builder fields

The configuration object takes these fields:

FieldTypeDescription
idstringRequired. The extension ID as a GUID. It's generated with the file, and it must be unique across extensions in the project.
namestringRequired. A name for the extension. Defaults to 'Data Collections'.
collectionsarrayRequired. The default export of each collection definition file to register.

Collection definition file

Each <collection-name>.ts file defines one collection. Its default export is a collection definition. A generated file starts with two fields and default permissions:

Copy

The file also exports collectionIdSuffix, the same string as idSuffix, so other code in the project can refer to the collection without repeating the string.

Collection fields

A collection definition takes these top-level fields:

FieldTypeDescription
idSuffixstringRequired. The last part of the collection ID. The full ID is the app namespace followed by / and idSuffix. 1 to 36 characters, using only letters, numbers, underscores, and hyphens.
displayNamestringThe collection's name in the CMS.
fieldsarrayRequired. The collection's fields. Each field has a key, a type, and an optional displayName.
displayFieldstringThe key of the field that identifies an item when another collection references it.
dataPermissionsobjectRequired. The role that each item action needs. The actions are itemInsert, itemRead, itemRemove, and itemUpdate.
indexesarrayIndexes that speed up queries on the collection.
initialDataarrayItems Wix adds when it creates the collection on a site. Each item must match fields.

For every field type, field option, and index option, and for the initial data format, see the Data Collections Extension JSON Reference.

Permissions

Each dataPermissions action takes one of these roles, from the most open to the most restricted:

  • ANYONE
  • SITE_MEMBER
  • SITE_MEMBER_AUTHOR
  • CMS_EDITOR
  • PRIVILEGED

For who each role includes, see About the Data Permissions API.

See also

Last updated: 2 November 2026

Did this help?