# Storefront Mode Setup

## Summary

* [ ] Ensure you have Node v12 or newer on your development machine
* [ ] `npx create-scandipwa-app my-app` to create a new app
* [ ] `cd my-app` to enter your app's directory
* [ ] `npm start` to run the app

These commands will create a new Scandi app, start it up, and open it in your browser.

## Creating a ScandiPWA App

You’ll need to have Node >= 12 on your local development machine (but it’s not required on the server). You can use [n](https://www.npmjs.com/package/n) (macOS, Linux) or [nvm-windows](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows) to switch Node versions between different projects.

To create a new app, you may choose one of the following methods:

{% tabs %}
{% tab title="NPX" %}

```bash
npx create-scandipwa-app my-app
```

{% endtab %}

{% tab title="NPM" %}

```
npm init scandipwa-app my-app
```

{% endtab %}

{% tab title="Yarn" %}

```
yarn create scandipwa-app my-app
```

{% endtab %}
{% endtabs %}

## Output

Running any of these commands will create a directory called `my-app` inside the current folder. Inside that directory, it will generate the initial project structure and install the transitive dependencies. More details:

{% content-ref url="../structure/folder-structure" %}
[folder-structure](https://docs.scandipwa.com/structure/folder-structure)
{% endcontent-ref %}

## Available Commands

Inside the newly created project, you can run some [built-in commands](https://docs.scandipwa.com/developing-with-scandi/developer-tools/available-commands):

### `npm start` or `yarn start`

Runs the app in development mode. Will open the [http://localhost:3000](http://localhost:3000/) to preview changes in your default browser.\
\
The page will automatically reload if you make changes to the code. You will see the build errors and lint warnings in the console.

### `npm run build` or `yarn build`

Builds the app for production to the `build` folder. It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.Your app is ready to be deployed.

## Connecting to a Magento server

By default, your new application will be fetching data from a remote store. If you want to use your own Magento instance, you can either create a new **CMA** ([by following this guide](https://docs.create-magento-app.com/getting-started/getting-started)) or set up a Magento instance manually. After that, you must configure it to include ScandiPWA-specific modules ([as described here](#configuring-the-magento-server)).

## Configuring the Magento server

To use Magento 2 as a data source for ScandiPWA, you are required to make sure that it is using the correct Composer dependencies. The list of your application Composer dependencies can be found in your ScandiPWA application's `composer.json` file.

You can copy the dependencies defined in `require` field of your application's `composer.json` to your Magento server's root `composer.json`  and execute the `composer update` command.
