dot CMS

How to Host Your dotCMS Headless App with Amplify

How to Host Your dotCMS Headless App with Amplify

Share this article on:

In this guide, you’ll learn how to host your dotCMS headless application on AWS Amplify. We begin by creating a Next.js app using the dotCMS example, setting the foundation for your headless setup. Once your Next.js app is in place, you’ll integrate it with Amplify for hosting and continuous deployment, allowing you to leverage Amplify’s robust features to keep your app up to date.

Prerequisites

  • Node.js (v20 or later) and npm installed

  • Basic familiarity with Next.js

  • Access to a dotCMS instance with sample content

  • An AWS Amplify account for hosting and deployment

  • A code editor for modifying configuration files

Create the app and download our Next.js example

Create a new Next.js app using our example

npx create-next-app my-dotcms-project --example https://github.com/dotCMS/core/tree/main/examples/nextjs

Open the project in your favorite editor, I'll be using Cursor.

Create a copy of the env.local.example file and name it env.local.

cp .env.local.example .env.local

Find a dotCMS auth token and add it to the env.local file.

curl -H "Content-Type:application/json"  -X POST -d  '

{ "user":"admin@dotcms.com", "password":"admin", "expirationDays": 10 }

' https://demo.dotcms.com/api/v1/authentication/api-token

Make sure to replace the user password and dotcms.com with your own.

Get the token and update the env.local file with it.

Now run the app to make sure it's working.

npm run dev

And you should see the app running on http://localhost:3000.

Push to a GitHub Repository

Amplify is a tool that allows you to deploy your app to AWS. You can use amplify-cli or the Amplify Console, in this case we'll use the Amplify Console.

So if you don't have an AWS account, now is a good time to create one. Once you have your AWS account, you can login to the Amplify Console and connect your repository.

So now we need to create the repository. So go to GitHub and create a new repository.

Make sure you are login into to you github account in your browser, if you don't have a github account, you can create one at https://github.com/

Then go to https://github.com/new and create a new repository.

how-to-host-your-dot-cms-headless-app-with-amplify-002

After creating the repository on GitHub, add it as remote and push

how-to-host-your-dot-cms-headless-app-with-amplify-003
git remote add origin git@github.com:USERNAME/REPO-NAME.git

git branch -M main

git push -u origin main

If you go back to the repository in your GitHub account and refresh the page, you should see something like this:

how-to-host-your-dot-cms-headless-app-with-amplify-004

What is Amplify?

AWS Amplify is a set of tools and services provided by Amazon Web Services (AWS) that helps developers build full-stack applications. It's tightly integrated with AWS services and provides:

  • Hosting and continuous deployment

  • Authentication

  • API management

  • Storage solutions

  • Analytics

  • Push notifications

The main benefit of using Amplify with AWS is that it abstracts away much of the complexity of working directly with AWS services, while still giving you the full power of AWS infrastructure. When you deploy through Amplify, your app automatically gets:

  • Global CDN distribution

  • CI/CD pipeline

  • HTTPS/SSL

  • Cache management

  • Custom domains support

In this case we're focusing on the hosting and continuous deployment.

So now we need to connect the repository to the Amplify Console.

But before starting you need to create an AWS account and configure. To do so go to https://aws.amazon.com/ and create an account.

Connect the repository to the Amplify Console

Go to your AWS account and search for Amplify Console.

how-to-host-your-dot-cms-headless-app-with-amplify-005

Click on the Amplify Console and then click on the "Deploy App" button.

how-to-host-your-dot-cms-headless-app-with-amplify-006

Now we are going to select Github for the source code of our app.

how-to-host-your-dot-cms-headless-app-with-amplify-007

And then you need to select the branch. Amplify is going to “watch” the branch you select for new comments and every time something new gets merged it will redeploy automatically. My base is main.

how-to-host-your-dot-cms-headless-app-with-amplify-009

The next step is to set all the special config for the Next.js if any, in our case the dotCMS Next.js example doesn't need any special configuration.

how-to-host-your-dot-cms-headless-app-with-amplify-010
  1. The build command is npm run build (default)

  2. The build output directory is .next (default)

And that’s it, but if in your case you need special configuration for your build, this is the place where you will let Amplify know.

Make sure that everything is ok and Click the button “Next”. You will get the preview page:

Make sure that everything is in ok or edit if you need, and then click “Save and Deploy”.

how-to-host-your-dot-cms-headless-app-with-amplify-011

Deploy

Here is where the Amplify magic starts to set up your environment

how-to-host-your-dot-cms-headless-app-with-amplify-013

Then you will see the building happening.

how-to-host-your-dot-cms-headless-app-with-amplify-014

Click in the branch to see the details.

how-to-host-your-dot-cms-headless-app-with-amplify-015

Here is where you can see the deployment happening in real time and the logs, in short what is doing:

  1. Pulling the code from your GitHub repository and your branch

  2. Running npm install

  3. Running npm run build for the production build

  4. And if all is good it will set a temporary domain.

But the first time you will see an error.

how-to-host-your-dot-cms-headless-app-with-amplify-016

Environmental Variables

When Amplify tried to build it needed the variables that we have in .env file but we didn’t push that file (of course we don't want to see those variables. So we need to set them up inside the Amplify UI.

So in the sidebar click in Hosting > Environmental Variables.

Now click on “Manage Variables” on the top right.

how-to-host-your-dot-cms-headless-app-with-amplify-018

Click in Add New

how-to-host-your-dot-cms-headless-app-with-amplify-019

Fill the key / values we have in .env file:

how-to-host-your-dot-cms-headless-app-with-amplify-020

And save the changes.

how-to-host-your-dot-cms-headless-app-with-amplify-021

Now go back to the deployment sections and click in “Redeploy this version”

how-to-host-your-dot-cms-headless-app-with-amplify-023

Wait a couple of minutes (it will depend on the size of your project) and it should deploy successfully.

how-to-host-your-dot-cms-headless-app-with-amplify-025

You site is live

Now click in the domain generated by Amplify and you should be able to see your site.

how-to-host-your-dot-cms-headless-app-with-amplify-026

Conclusion

This guide has walked you through building your Next.js app with the dotCMS example and integrating it with AWS Amplify for hosting. By following these steps, you not only set up a scalable deployment pipeline but also streamline ongoing updates to your headless application. With your app now live on Amplify, you’re well-positioned to further optimize your deployment process and extend your app’s capabilities.

QA Section

Why is my Next.js build failing on Amplify?
Check the Amplify build logs for errors. Build failures often result from misconfigured environment variables, incompatible Node.js versions, or issues in your code. Try running npm run build locally to catch errors before deploying.

What should I do if the dotCMS API is not responding?
A: Verify that the dotCMS instance is running and accessible, and ensure the API URL and tokens are correctly set in your environment variables. Testing API endpoints locally can also help pinpoint connectivity issues.

How can I resolve issues with environment variables not being picked up?
A: Ensure all required environment variables (e.g., API tokens, dotCMS URL) are properly defined in your local setup and in the Amplify environment settings. Misconfigurations here are a common source of errors.

What if my application is not reflecting recent changes after deployment?
Confirm that the continuous deployment process is correctly set up on Amplify. Additionally, clear any caches or force a redeployment to ensure that the latest code is being served.

How do I debug integration issues with the dotCMS example in my Next.js app?
Compare your code with the dotCMS example to identify discrepancies. Use local testing and logging to isolate errors. Running npm run build locally can reveal build-time issues that might not be immediately apparent during development.

Recommended Reading
  • Migrating Your OSGi Plugins to dotEvergreen: Adapting to the New Index API
    24 Mar 26
    Technical Guides

    Migrating Your OSGi Plugins to dotEvergreen: Adapting to the New Index API

    An update on infrastructural changes, information on a breaking change introduced that may affect some plugins, and a migration guide for those affected.

    Fabrizzio

    Fabrizzio Araya

    Staff Software Engineer

  • What Is Rich Text? How It Works in a Headless CMS
    23 Mar 26
    Content Management

    What Is Rich Text? How It Works in a Headless CMS

    What is rich text, and how does it differ from Rich Text Format (.rtf)? Learn how rich text works in content management systems, how headless CMS platforms store it as structured data, and why the format matters for omnichannel delivery.

    Fatima

    Fatima Nasir Tareen

    Growth Marketing Specialist

  • Structured Content for GEO: How dotCMS Powers AI-Ready Digital Experiences
    21 Mar 26
    AI in CMS

    Structured Content for GEO: How dotCMS Powers AI-Ready Digital Experiences

    Discover how dotCMS revolutionizes AI-driven digital experiences with structured content for Generative Engine Optimization (GEO). Learn how our enterprise solution enhances AI visibility, enabling large language models to accurately process and cite machine-readable data. Dive into best practices for creating AI-ready content and explore the benefits of a headless CMS model. Optimize your content for AI discovery and experience seamless omnichannel delivery. Contact us to leverage dotCMS for your AI-powered search needs.

    Fatima

    Fatima Nasir Tareen

    Growth Marketing Specialist

  • AI Content Governance for Content Teams: A Practical Framework
    9 Mar 26
    AI in CMS

    AI Content Governance for Content Teams: A Practical Framework

    Learn why AI content governance is essential for content teams. Discover how to protect brand consistency, reduce legal risk, and manage AI across dozens of sites with dotCMS’s built-in governance tools.

    Fatima

    Fatima Nasir Tareen

    Growth Marketing Specialist

Explore dotCMS for your organization

image

dotCMS Named a Major Player

In the IDC MarketScape: Worldwide AI-Enabled Headless CMS 2025 Vendor Assessment

image

Explore an interactive tour

See how dotCMS empowers technical and content teams at compliance-led organizations.

image

Schedule a custom demo

Schedule a custom demo with one of our experts and discover the capabilities of dotCMS for your business.