How to Create a Custom Starter in Prismic

Learn how to reuse code, slices, and types across projects.

With starters, you can skip much of the boilerplate involved in setting up a website. If you create many websites (for clients or internal use), starters might save you a lot of time.

  • Starters will let you reuse slices and types across projects (especially if your projects have the same structure).
  • Starters can take care of boilerplate code, like search, analytics, components, and animations.

Creating a starter

To create a starter, you’ll need a working Prismic project as a base and a GitHub repository for your project code.
Either create a basic project with your boilerplate — third-party integrations, components, routes, pages, types, slices, and styles or use an existing Prismic project.

Create a new GitHub repository for your starter and push all of your files.

Using your starter to create a new repo

To use your custom starter, clone your starter project from GitHub:

git clone https://github.com/your-project-url.git

Then cd into your new directory:

cd your-project-name

Then init Slice Machine:

npx @slicemachine/init@latest --repository your-project-name

The commands will do the following:

  • Start a new Prismic project using this starter.
  • Ask you to log in to Prismic or create an account.
  • Create a new Prismic content repository with the models in your cloned project.

After that, run your project and you’re ready to continue customizing from there.

npm run dev

Set up the languages in your repository

Go to your newly created repository in Prismic https://your-repository-name.prismic.io and choose your master locale from the popup.

Add documents from your starter repository to your new repository (optional)

Follow the steps below to add all documents and assets from your starter repository to your new repository:

Download the script and install dependencies:

git clone https://github.com/prismicio-solution-engineering/repo-clone-script
cd repo-clone-script
npm install

Configure the script with a .env file. There is an .env.sample file provided in the script.

Run the script using the following command

npm run start -- YOUR_PROJECT_NAME

Running this script will do the following:

  • Retrieve all published documents from your starter repository via the Document API.
  • Upload all assets in those documents into your new repository’s media library via the Prismic Asset API.
  • Prepare requests to the Migration API in the required format.
  • Create all master language documents from your starter in your new repository. These documents will now be available in the Migration Release screen of your new repository.