For this project we used NextJS to build a JamStack Website which data (pages and content) came fully from DotCMS.
Additionally we have a server NodeJS that allows you to edit your JamStack pages from DotCMS.
If you want information on how we build all this, you can see these two videos:
- Build and deploy your Jamstack with NextJS and GraphQL
- Making your Jamstack application editable in real-time with dotCMS
DotCMS as a hybrid CMS allows you not only edit regular pages, Single Page Apps or any kind of JamStack websites.
We are using the latest NextJS features to statically render all the DotCMS pages and publish it to Vercel and Heroku
With the release of NextJS 9.4 you can use its Static Site Generator feature to create static DotCMS pages in build time, this is the approach we took here, in a overview we:
- We pull all the pages from DotCMS instance
- Statically generate each page with React Components
- Publish to Vercel
Run yarn
Run yarn setup
and follow the instructions
Run yarn dev
this will start you NextJS application in development mode with hot-code reloading, error reporting, and more.
Run yarn build
creates an optimized production build of your application. The output displays information about each route, more information.
Run yarn start
starts the application in production mode. The application should be compiled with next build
first, more information
We are using NextJS but with a custom NodeJS with Express framework.
To run locally and test your EMA server, run yarn ema
We have two deploys here, one to Vercel (our JamStack Website) and the Edit Mode Anywhere Server to Heroku
- Run
yarn install
- Run
yarn setup
2.1 This command will setup a.env
file for you.- If you don't have an
.env
file in your project then select 'Y' in the first question. - In
DotCMS URL
enter the DotCMS instance where your data is stored - Public URL is the URL where you deploy your server. (Preferably Heroku or a non-serverless platform)
- Enter the username and password of the DotCMS instance.
- If you don't have an
- Install the vercel cli with
yarn global add vercel
- Login to Vercel from the terminal with
vercel login
- Deploy with
vercel --prod
- Run
yarn install
- Run
yarn setup
if you don't have an.env
file and follow the steps 2.1 from the section "Deploy to Vercel" - Install the heroku cli with
brew tap heroku/brew && brew install heroku
- Login to Heroku from the terminal with
heroku login
- Run
heroku create
to create a new project in Heroku. 5.1. This command will return a URL that we will use as theDEPLOY_URL
environment variable (e.g. https://app-random-name.herokuapp.com) 5.2 Go to the.env
file and update theDEPLOY_URL
environment variable - Go to https://dashboard.heroku.com/apps > app-random-name > Settings > Config Vars > Reveal Config Vars and paste all your environment variables.
- Deploy with
git push heroku master
- Install Docker
- Build the image:
docker build -t dotcms/dotcms-spa:YOUR_VERSION .
- Run locally:
docker run -p 5000:5000 dotcms/dotcms-spa:YOUR_VERSION