In this tutorial, Today I will explain to how to call cms static block in Magento 2 PWA. CMS Static Block is best way to manage your content with dynamically to display on Frontend side. It will be useful for promotional banner, offers banner etc.
Now, if you created your PWA store with Magento then, you need to also use cms block functionality. So, Question is that how to use CMS static block in Magento 2 PWA.
You may also like this :
- Magento 2.3 PWA Installation Guide
- How to Add Custom Font in Magento 2 PWA
- How to Create Custom Router in Magento 2 PWA
let’s assume that you have created component. Now, You need to import this below line in your component’s js file.
import CmsBlock from '@magento/venia-ui/lib/components/CmsBlock';
After that, You need to add this line in your render() function.
<CmsBlock identifiers={'cms-block-homepage-top'} />
Here, you need to write cms block identifier in identifiers attribute. Using, this syntax you can display cms block content. If you want to display multiple block content then, you can use this below line :
<CmsBlock identifiers={['cms-block-homepage-top','cms-block-homepage-bottom']} />
After that, You can check on frontend side that your cms block content will display successfully.
That’s it !!!
I hope this blog is easy to understand about how to call CMS static block in Magento 2 PWA. In case, I missed anything or need to add some information, always feel free to leave a comment in this blog, I’ll get back with proper solution.
Stay Safe and Stay Connected !!