Walkthrough: Getting started with JSS for React
This walkthrough describes how to create and run your first JSS React application.
Before you can create and run an application with JSS for React, you must first:
-
Familiarize yourself with the available application modes for JavaScript apps built with JSS.
-
Install the JSS CLI.
This walkthrough describes how to:
-
Create the application.
-
Run the application.
Create the application
To create an application with JSS for React:
-
Run the following command:
RequestResponsenpx create-sitecore-jss@ver<version-number> react [--appName <your-app-name> --fetchWith [REST| GraphQL]]
Replace
<version-number>
with the version you wish to use. For example,21
.NoteIf choosing GraphQL, your application must be connected to Sitecore. GraphQL requests are not supported in disconnected mode.
Run the application
To start your application, run one of the following scripts in a terminal, depending on your chosen development workflow:
You can find script definitions in the package.json
file of your new JSS application.
-
If you do not have a Sitecore instance available, start the application in disconnected mode:
RequestResponsejss start
-
If you have a Sitecore instance and want to develop against it, connect and deploy your JSS application to Sitecore and start the application in connected mode:
RequestResponsejss start:connected