Blocks allows you to connect a CMS database collection to a dynamic repeater using code. Note that alternatively, you can connect a repeater to data with no code.
The @wix/data
SDK cannot be tested in the Blocks Preview. Test your app on a site to see it work.
To connect a dynamic repeater to a collection:
Create or open a Blocks widget.
Go to the Add + panel and add a dynamic repeater to your widget.
Go to the Code {} tab and import the @wix/data
npm package.
Go to widget code panel and import the @wix/data module:
Go to the CMS tab and open Your Collections. If you haven't created a collection yet, create one now.
Click the three dots next to the collection name and then Edit Settings, to copy the collection ID. It should look something like this:
Query the data in the collection and use it to populate the repeater. For example:
For an additional example, refer to this tutorial. While the tutorial focuses on standard repeaters used in site building, the same principles apply to dynamic repeaters in Blocks. When adapting the tutorial for Blocks, make sure to add the app namespace before the collection name in your query.