Last reviewed: April 22, 2025

Initialize a new Content Publisher Next.js site

This guide walks you through setting up a new Next.js website as a client of Content Publisher from Content Publisher’s starter kit


Prerequisites

Before proceeding, please ensure you have a NextJS-ready development environment available. You’ll need Node and NPM.

Next.js installed

If this is not yet the case, download the latest version of Node.JS for your OS:

  1. Go to https://nodejs.org/en/download/package-manager and follow the instructions there (we recommend running each command individually vs the full command at once).
  2. Install Node.js - for this field select the latest version with LTS.
  3. OS - Select the operating system (OS) where you will be installing Node.JS.
  4. Using - We recommend using NVM, although select the package manager that you are comfortable with.

Note that we currently require Node v.18x to install. Please let us know if your team requires a lower Node version ([email protected]).

Content Publisher CLI installed

If this is not the case, run the following command to download and install the CLI.

npm add @pantheon-systems/pcc-cli --global

Setup

Logging In

To login to the CLI, run:

pcc login

You will need a Google account to login. This command will open a tab in your web browser where you can either select an already logged-in Google account or login to a new one.

Initialize a new NextJS project with Content Publisher

To initialize a new NextJS project with Content Publisher, run:

pcc init <project-name>

The project name can be anything you want. It is just the name of the project to create, not the name of the Content Publisher site you are going to associate with the project.

Also, the above command creates a project in Javascript. To create the project using Typescript and eslint, run:

pcc init <project-name> --ts --eslint

This also creates a project where the package manager is npm. To set it up using pnpm, run:

pcc init <project-name> --use-pnpm

The above commands also install all the dependencies while setting up. In order to avoid that, run:

pcc init <project-name> --noInstall

While the project is being setup, the flow asks whether a site (aka collection) needs to be picked now. Type ‘y’ if the site (aka collection) already exists and you want to connect the project to it. It shows the list of existing sites and you can select one from the list. If not, just type ‘n’ and it can be set up later.

It also asks whether a token needs to be created. If you don't already have a token, type ‘y’. If you do, type ‘n’ and it can be set up later.

Configuring the project with the Collection ID and Token

If you selected ‘n’ for the option of selecting a site and token while setting up the project, you can create the collection later and/or create a token manually. Then you can open the .env.local file at the root of the project and update the values there with the ones you created.

Updating a site’s URL

Once a site is deployed, there may be a need to update the URL of the content publisher collection (aka site) connected to that site with the new URL. To do that, run:

pcc site configure <site-id> --url "<new-url>"

Where the new URL is the URL of the newly deployed site in the form of https://site-url.com.