The JSS app initializer
The Sitecore JavaScript Rendering SDK (JSS) provides the create-sitecore-jss
package that contains an app initialization script and JSS application templates for popular JavaScript frameworks and application add-ons.
To use the JSS initializer, in a terminal, you can run one of the following commands:
npx create-sitecore-jss
To provide any arguments, use the npx
command.
When you use the JSS initializer commands, you create a JSS application using the latest JSS version, which might include features and functionality available only for newer versions of the platform.
Therefore, you must identify the JSS version compatible with your Sitecore version and provide the version tag to the JSS initializer. For example: npx create-sitecore-jss@ver20
.
Required arguments
When creating a JSS application with the initializer, you can follow the prompts to provide information about the setup you want for your application.
Alternatively, you can override any prompt by passing in that value as a flag using the following arguments:
Argument |
Type |
Description |
---|---|---|
|
|
A comma-separated list of template names to use in scaffolding the JSS application. It can include the name of a base app template, for example, For example, You can also supply a list of templates using the positional argument: |
|
|
The name of your JSS application. Default: sitecore-jss-app. |
|
|
Path/directory for the application. If you provide a non-empty directory path, the initializer shows potential changes to existing files. It also provides options for handling the change (approve the changes to the current file, skip the file, approve changes to all files, or abort). Using the initializer in a non-empty destination is useful when you want to apply add-on templates to your existing JSS project. Default: <current-directory-path>/<base-template-name>. |
|
|
Method for fetching data. Choose Default: GraphQL. |
|
|
Only available if using the Default: SSG. |
|
|
Only valid if using the Default: da-DK. |
|
|
The hostname of your Sitecore instance. Default: <app-name>.dev.local. |
For example, if you want to skip the templates
, appName
, and fetchWith
prompts, you can run the following command:
npx create-sitecore-jss --templates nextjs --appName my-nextjs-app --fetchWith GraphQL
You can shorten the command by using the positional argument as follows:
npx create-sitecore-jss nextjs --appName my-nextjs-app --fetchWith GraphQL
Optional arguments
In addition to the required arguments, the JSS initializer accepts the following optional parameters:
Argument |
Type |
Description |
---|---|---|
|
|
If present, the application:
|
|
|
If provided, suppresses any questions related to file system operations, and the initializer runs default actions. |
|
|
If provided, suppresses log messages. Usage: |
|
|
If provided, suppresses any questions related to the CLI argument values, and the initializer uses the default values. |
Base templates
When creating a project, you can provide one base template name using the positional argument or by using the --templates
flag:
npx create-sitecore-jss <base-template-name>
Or:
npx create-sitecore-jss --templates <base-template-name>
The available base template names are:
-
nextjs
. -
react
. -
angular
. -
vue
. -
react-native
. -
node-headless-ssr-experience-edge
. -
node-headless-ssr-proxy
.
Add-on templates
When creating a project, in addition to the base template name, you can also provide multiple add-on template names using the positional argument or the --templates
flag:
npx create-sitecore-jss <base-template-name>,<first-add-on-template-name>,<second-add-on-template-name>
Or:
npx create-sitecore-jss --templates <base-template-name>,<first-add-on-template-name>,<second-add-on-template-name>
The available add-on template names are:
-
nextjs-styleguide
- includes example components and the setup for working disconnected. -
nextjs-sxa
- includes JSS SXA headless components. This add-on template is only compatible with a Sitecore Experience Manager Cloud (XM Cloud) content management instance.