JSS initializer parameters
This topic lists all valid parameters you can include when using npx to initialize a local JSS application. Using them will reduce the number of questions you're asked while running the JSS initializer.
These parameters are not available when using other package managers such as npm or yarn to initialize a JSS app.
The base app template and add-ons
Every JSS app is based on a starter template, which determines the framework that powers the app. The templates parameter accepts a comma-separated string list containing the name of the base app template and the names of any add-ons you want the app to include.
The templates list must include one of the following base app templates names:
-
nextjs -
angular
Depending on the chosen base app, you also need to include one of the following SitecoreAI add-ons:
-
node-xmcloud-proxy- required for non-Next.js (such as Angular) apps to connect to SitecoreAI. -
nextjs-xmcloud- required for Next.js apps to connect to SitecoreAI.
If you only specify a base app template, the initializer will ask you whether you're building for SitecoreAI and, if so, it will install the required add-on automatically.
Some code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.
Lastly, you can specify add-ons relevant to the chosen base template, such as:
-
nextjs-sxa- an important add-on for Next.js JSS apps for SitecoreAI. It includes configurations for Next.js headless projects as well as Sitecore Experience Accelerator (SXA) example components. You should always include this add-on when working with the Next.js starter template. -
nextjs-multisite- an optional add-on that includes an example setup for hosting multiple sites from a single Next.js application.
The nextjs-styleguide add-on is not relevant for SitecoreAI apps, and it is not compatible with nextjs-sxa, so you can ignore it.
The following example command initializes a Next.js app with the SitecoreAI and SXA add-ons.
When placing the templates parameter first like this, you can omit --templates and write the list as is, such as:
Some code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.
Main parameters
All of these parameters are optional, but using them lets you quickly create apps based on common settings without having to answer all the standard questions during the initialization process.
All of these parameters accept string values.
|
Parameter |
Description |
|---|---|
|
|
The name of your JSS application. Default: |
|
|
Path or directory for the new application. If you provide a path that already contains files, the initializer will warn you and confirm that you want to proceed. For the files potentially changed by the initializer, you'll have the option to approve changes for each file, skip individual files, approve changes to all files, or abort the process. Using the initializer in a non-empty destination helps you apply add-on templates to an existing JSS app. Default: |
|
|
Method for fetching data. You can choose Default: |
|
|
Only available if using the Default: |
|
|
Only valid if using the Default: |
|
|
The hostname of your Sitecore instance. Default: |
For example, if you use the following command, you won't be prompted to choose templates, an app name, or a fetch method while initializing your app:
Some code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.
Optional parameters
These optional parameters can be added to your npx command to modify the JSS app initialization process, based on your preferences.
These parameters do not take a value. Including one of them will apply an effect as described in the following table.
|
Parameter |
Effect when included |
|---|---|
|
|
Instructs the application to do the following:
|
|
|
Skips all initializer questions related to file system operations, choosing the default option for each. |
|
|
Hides all log messages while the initializer is running. |
|
|
Each time you push changes to your remote repo, runs a linting script that validates all TypeScript types and code formatting. |
|
|
Skips all initializer questions related to CLI argument values, choosing the default option for each. |
|
|
The initializer uses the |
Some code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.