
Self-hosted Headless Shopify
Is it possible to self-host a Headless Shopify store?
Yes and no.
Shopify itself is a managed platform, and can’t be self hosted.
However, headless Shopify builds have much more flexibility — and some of their components can be self-hosted. This depends on the nature of the rest of your tech stack (all the bits that aren’t Shopify).
Self-hosting the JavaScript frontend framework
React-based frameworks are a popular choice for headless Shopify frontends, the most popular of which are Next.js, Hydrogen, Remix, and Astro. All of these projects are open source, most under the MIT license. This makes them free to use and possible to host on any infrastructure that can support them. In this way, the decoupled frontend of a headless Shopify build can be self-hosted—whether on remote infrastructure that you pay for, or on bare metal that your organization owns and controls.
The ability to self host is an important consideration for many businesses, as it provides the ability to control, service, and maintain the infrastructure at a granular level, ensuring any compliance-related requirements are satisfied.
This enables Shopify to remain servicing the build via APIs, while you retain control over everything related to the frontend.
Self-hosting the headless CMS
Many Headless Shopify stacks involve the implementation of a Headless CMS, of which there are both proprietary and open-source options available. For open-source CMSes, these can be hosted on your own infrastructure, and even patched or extended as required in order to deliver on your specific usage requirements.
Some examples of open-source headless CMSes that can be used as part of a headless Shopify build are:
- Strapi
- Directus
- Payload
Beyond these headless-era stalwarts, more traditional content management systems can also be used in their place, to deliver rich and integrated experiences for Headless Shopify stores. Some more open-source legacy CMSes that can be configured for headless environments:
We're the experts in Headless Shopify.
Your search for answers ends here. Discover our services.
Explore Headless Shopify Services- Headless WordPress
- Headless Drupal (using the core modules JSON:API or REST)
All of these options are viable for a headless Shopify build, and all can be self-hosted.
The database for the headless CMS can also be self-hosted
Most self-hosted open-source headless CMSs require a database, with the exception of flat-file CMSes such as Decap (previously Netlify CMS), which rely on JSON or Markdown files.
Strapi, for example, is compatible with PostgreSQL, MySQL/MariaDB, and SQLite.
This kind of database can be hosted practically anywhere – from remote cloud infrastructure to a self-maintained server rack.
Self-hosting media assets through Static File Storage
Files and media assets that originate either from Shopify or your headless CMS can typically be hosted wherever you please. Most open-source headless CMSes provide plugins, connectors or providers that can be swapped out to determine the location for media storage, from S3 buckets to file-hosting SaaS platforms. Of course, these can also default to a local directory or self-hosted S3 bucket.
As for frontend Javascript frameworks, several of these (such as Gatsby) provide their own built-in image transformation tool-suites, which cache media files locally and store them to a static build folder; which you can self-host and configure to your choosing.
A consideration with regards to continuous deployment
A truly self-hosted setup will naturally require a great deal more infrastructure setup when compared to a plug-and-play cloud platform. From an agile development point of view, the availability of a CI/CD pipeline within the self-hosted environment is a necessary consideration and will go a long way in smoothing over the timeliness of production deployments.
This is perhaps the most challenging part to implement, as a productive infrastructure setup requires the ability for developers to push to multiple environments and collaboratively review changes prior to merging these to the main branch.
Tools like GitHub Actions can assist in the implementation of this — or a self-hosted instance of Coolify can provide a fully self-hosted solution.
Think about security
While self-hosting has its benefits, your organization is potentially taking on a tall-order in terms of ensuring the ongoing security of any components of the self-hosted headless Shopify stack. It may well (and probably does) work out cheaper to host via managed cloud, where critical patches and maintenance is taken care of. Your team has a business to run, after all.
Self-hosted infrastructure is not "set-and-forget". It will require upkeep, proactive monitoring, and additional measures such as failover implementation, and potential security patches over time.
JS frontend aside (these aren't so readily prone to meaningful vulnerabilities), the Headless CMS and — most importantly — its database, will require conscious maintenance and monitoring into the future to ensure things are patched and secured in response to potentially-arising vulnerabilities.
Informal chat? Works for us. 🤘
Contact Cocoon for a no-cost, no-obligation consultation.
Let's talk ShopifyBackups should remain an important consideration
The majority of production-ready cloud & infrastructure providers boast backup and snapshot functionalities as standard. Often, a comprehensive automated backup schedule can be configured in a few clicks within managed or semi-managed platforms such as DigitalOcean.
For any self-hosted components of a headless Shopify build – such as a headless CMS, its database, or self-hosted static file storage – it would be foolish to forgo a reliable backup automation schedule.
In self-hosted environments, configuring a backup mechanism will require additional resources to initially set up, and also requires some form of ongoing maintenance to ensure backups remain viable and continue to succeed. Depending on the timescale for which backups are retained, there will also be additional storage costs involved.
When considering self-hosting components of the stack, it would be prudent to fully cost and consider each individual aspect, to ascertain the true total cost of ownership (TCO) and whether this actually compares favorably to the comparable costs of a production-grade cloud platform.
You may find yourself surprised at the TCO imposed by truly self-hosting, and questioning whether it's actually worth it.
Got more questions? Speak with a Pro.
More on Headless Shopify
Let's talk Shopify.
We build modern digital experiences for disruptive brands.
Tell us about your project, and we'll get back to you with details on how we can make this happen.