Tailwind Logo

Creating a project that does not include Next.js sample data

Next.js

Published: 2021-12-22

With the release of Sitecore version 10.2, Sitecore Headless Services also upgraded to version 19.0.0. New steps were added for creating projects without Next.js sample data, saving time by skipping data deletion in initial steps. Let's update.

Regarding the version of the jss command

command must be updated to the latest version. The following results were displayed when the version was checked.

Bash
github % jss --version
JSS CLI is running in global mode because it was not installed in the local node_modules folder.
19.0.0

You can see that the 19.0.0 command is installed.

Create a Next.js project

First, create a project as before.

Bash
jss create nextjs-test nextjs

When the creation is completed, the following message is displayed.

nextjs01.png

The explanation is given in the Next.js sample app parameter shown at the end.

Plain Text
* --fetchWith {REST|GraphQL} : Specifies how Sitecore data (layout, dictionary) is fetched. Default is REST.
* --prerender {SSG|SSR} : Specifies the Next.js pre-rendering form for the optional catch-all route. Default is SSG.
* --empty {true|false} : Specifies whether the sample should be empty. Disconnected mode and styleguide components will be removed. Default is false.

The third --empty introduces the point that the sample data will be implemented in a deleted form. So, once again, we will create a project with the following parameters.

Bash
jss create nextjs-demo nextjs --empty

In the new directory you created, you can see that the directory under /src/components is empty. Similarly, there is no /data directory at the top level.

nextjs02.png

To make it work, data and components must be added.

2022-02-22 Postscript: This empty sample is used in the "Change to Sitecore First" section.

Summary

When a new version of a headless site is needed, the necessary data can be migrated to this empty template. This feature will be useful in the future.

Related article

Tags