These integration guides are not official documentation and the Strapi Support Team will not provide assistance with them.
What Is Shopify?
Shopify is a leading e-commerce platform that allows businesses to create, manage, and scale their online stores. Shopify provides a range of customizable templates, tools, and features designed to streamline the process of selling products online.
With Shopify, entrepreneurs and established businesses alike can manage inventory, process payments, and track orders from a centralized dashboard. It also integrates with various third-party apps and services to extend functionality, such as marketing, shipping, and accounting. Known for its user-friendly interface, Shopify is a popular choice for both beginners and experienced merchants looking to build and grow their e-commerce presence.
Why Use Strapi With Shopify?
Integrating Strapi’s headless CMS with Shopify enhances the flexibility of your e-commerce site while leveraging Shopify’s robust commerce infrastructure. Shopify handles product data, inventory, and transactions, while Strapi manages rich content, marketing materials, and custom experiences. By connecting these platforms via eCommerce and Strapi API integrations, you can seamlessly manage your online store’s content and commerce.
Key Benefits of Integrating Shopify with Strapi
The primary benefit is content flexibility. While Shopify excels in product management, it can be limiting when it comes to complex editorial experiences. Strapi, as a customizable headless CMS, allows for rich product narratives, multilingual content, and sophisticated landing pages, all seamlessly integrated with your Shopify data.
The performance also improves. By separating content management from e-commerce, you can optimize each system independently. Content can be cached through CDNs, while product data remains dynamic. This separation typically can boost page load speeds and increase conversion rates.
Additionally, you’re no longer confined by Shopify’s theme limitations. Strapi lets you build progressive web apps, mobile apps, or use any frontend framework while retaining full commerce functionality—perfect for frontend developers.
Architectural Advantages
This headless approach enables each system to scale independently, addressing the limitations of traditional CMS setups. With Strapi, your content team can work efficiently while Shopify handles commerce operations smoothly. Plugins make setup simple, ensuring real-time data synchronization through webhooks and secure API connections. Technologies like GraphQL further enhance data querying capabilities, offering developers robust tools for building advanced e-commerce applications.
Keep in touch with the latest Strapi and Shopify updates
How to Integrate Strapi with Shopify
This step-by-step guide covers the complete integration process, from initial setup to a fully functional Shopify-Strapi connection.
Prerequisites
Your system needs 2 CPU cores and 4GB of RAM minimum (8GB recommended) with at least 32GB of disk space. Install Node.js and npm/yarn. Choose PostgreSQL for production or SQLite for development.
You'll need an active Shopify store with admin access to create private apps and configure webhooks.
Setting Up Your Strapi Project
Create your Strapi project and build for production:
1npx create-strapi-app@latest my-shopify-project
2cd my-shopify-project
3NODE_ENV=production npm run build
Select PostgreSQL during setup and provide your database connection details.
Configuring Shopify API Access
In your Shopify admin, navigate to Apps and click on 'Develop apps' in the top right. Create a new app with these permissions:
- Read access: products, orders, customers
- Write access: products (if updating from Strapi)
Generate your API credentials and install the official Shopify Node.js library:
1npm install @shopify/shopify-api
Enforcing Secure Credential Management
Create a .env
file (add to .gitignore
):
1SHOPIFY_API_KEY=your_api_key_here
2SHOPIFY_API_SECRET=your_api_secret_here
3SHOPIFY_ADMIN_API_ACCESS_TOKEN=your_access_token_here
4SHOPIFY_SHOP_NAME=your_shop_name
5SHOPIFY_API_VERSION=2023-04
6SHOPIFY_WEBHOOK_SECRET=your_webhook_secret_here
Create a configuration file:
1// config/shopify.js
2module.exports = ({ env }) => ({
3 apiKey: env('SHOPIFY_API_KEY'),
4 apiSecret: env('SHOPIFY_API_SECRET'),
5 accessToken: env('SHOPIFY_ADMIN_API_ACCESS_TOKEN'),
6 shopName: env('SHOPIFY_SHOP_NAME'),
7 apiVersion: env('SHOPIFY_API_VERSION'),
8 webhookSecret: env('SHOPIFY_WEBHOOK_SECRET')
9});
Implementing Webhooks for Data Synchronization
Set up webhooks for product events in Shopify via the Admin API or through your app's configuration in the Shopify Partners dashboard. If you're new to this, here's a guide on using webhooks in Strapi. For local development, expose your environment using Hookdeck CLI:
1npm install -g @hookdeck/cli
2hookdeck listen 1337/api/shopify/webhook
Create a webhook controller:
1// api/shopify/controllers/webhook.js
2'use strict';
3
4const crypto = require('crypto');
5
6module.exports = {
7 async handleProductWebhook(ctx) {
8 const hmac = ctx.request.headers['x-shopify-hmac-sha256'];
9 const calculatedHmac = crypto
10 .createHmac('sha256', process.env.SHOPIFY_WEBHOOK_SECRET)
11 .update(JSON.stringify(ctx.request.body), 'utf8')
12 .digest('base64');
13
14 if (calculatedHmac !== hmac) {
15 return ctx.unauthorized('Invalid webhook signature');
16 }
17
18 const webhookTopic = ctx.request.headers['x-shopify-topic'];
19 const productData = ctx.request.body;
20
21 switch (webhookTopic) {
22 case 'products/create':
23 await strapi.services.product.create({
24 shopifyId: productData.id.toString(),
25 title: productData.title,
26 description: productData.body_html,
27 price: productData.variants[0].price
28 });
29 break;
30 case 'products/update':
31 await strapi.services.product.updateByShopifyId(
32 productData.id.toString(),
33 {
34 title: productData.title,
35 description: productData.body_html,
36 price: productData.variants[0].price
37 }
38 );
39 break;
40 }
41
42 return ctx.send({ received: true });
43 }
44};
Testing Your Integration
Create a test product in Shopify and verify the webhook creates a corresponding Strapi entry. Monitor webhook delivery through Shopify's admin interface logs.
Test automated scenarios:
1// tests/integration/shopify.test.js
2describe('Shopify Integration Tests', () => {
3 it('should create product from webhook', async () => {
4 const testProduct = {
5 id: 123456789,
6 title: 'Test Product',
7 body_html: 'Test description',
8 variants: [{ price: '29.99' }]
9 };
10
11 const response = await request(strapi.server)
12 .post('/api/shopify/webhook')
13 .set('x-shopify-topic', 'products/create')
14 .set('x-shopify-hmac-sha256', calculateHmac(testProduct))
15 .send(testProduct);
16
17 expect(response.status).toBe(200);
18
19 const createdProduct = await strapi.services.product.findOne({
20 shopifyId: '123456789'
21 });
22 expect(createdProduct.title).toBe('Test Product');
23 });
24});
Your integration is now ready for production deployment. You can begin building content-driven shopping experiences that differentiate your store from the competition.
Keep in touch with the latest Strapi and Shopify updates
Example Project: Build an E-commerce Backend with Shopify and Strapi
This e-commerce solution demonstrates production-ready Shopify-Strapi integration patterns. The project combines Shopify's commerce engine with Strapi's content management flexibility to create a scalable headless commerce platform.
Project Structure
The modular architecture maintains a clear separation between commerce and content operations:
1strapi-shopify-integration/
2├── api/
3│ └── shopify/
4│ ├── controllers/
5│ ├── services/
6│ └── routes/
7├── config/
8│ ├── shopify.js
9│ └── middleware.js
10├── plugins/
11└── webhooks/
This structure supports secure webhook handling and automated data synchronization. The project includes Strapi plugin configuration for seamless Admin API integration.
Key Implementation Details
The project addresses critical integration challenges through proven patterns. Here's an example of the HMAC verification implementation that secures your webhook endpoints:
1// api/shopify/services/webhook.js
2const crypto = require('crypto');
3
4module.exports = {
5 verifyShopifyWebhook(data, hmacHeader, secret) {
6 const generatedHash = crypto
7 .createHmac('sha256', secret)
8 .update(data, 'utf8')
9 .digest('base64');
10
11 return crypto.timingSafeEqual(
12 Buffer.from(generatedHash),
13 Buffer.from(hmacHeader)
14 );
15 },
16
17 async processProductUpdate(productData) {
18 // Synchronize product data with Strapi
19 const existingProduct = await strapi.query('product').findOne({
20 shopifyId: productData.id
21 });
22
23 if (existingProduct) {
24 return strapi.query('product').update(
25 { id: existingProduct.id },
26 {
27 title: productData.title,
28 description: productData.body_html,
29 price: productData.variants[0].price,
30 // Additional fields...
31 }
32 );
33 } else {
34 // Create new product logic
35 }
36 }
37};
The synchronization service maintains data consistency with automatic retry mechanisms for failed API calls.
The implementation utilizes the @strapi-community/shopify plugin with custom controllers for advanced functionality. Product lifecycle events (creation, updates, deletions) trigger webhook handlers that maintain synchronization between both systems. The Shopify Fields plugin extends content management capabilities beyond standard commerce fields.
To set up the project locally:
- Clone the repository
- Configure Shopify API credentials in your
.env
file - Register webhook endpoints in your Shopify admin panel
- Run
yarn develop
to start your Strapi instance - Test the integration with a sample product creation
This foundation handles production-scale traffic while maintaining security standards and performance requirements for enterprise e-commerce applications.
Keep in touch with the latest Strapi and Shopify updates
Strapi Open Office Hours
If you have any questions about Strapi 5 or just would like to stop by and say hi, you can join us at Strapi's Discord Open Office Hours, Monday through Friday, from 12:30 pm to 1:30 pm CST: Strapi Discord Open Office Hours.
For more details, visit the Strapi documentation and the Shopify documentation.