# React External App

An external React starter template for customer-facing apps on the Salesforce platform. Includes authentication, global search, and an Experience Cloud site container. Built with React, Vite, TypeScript, and Tailwind/shadcn.

## What's included

| Path                                                 | Description                                                                                                                                        |
| ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `force-app/main/default/uiBundles/reactexternalapp/` | React UI Bundle (source, config, tests)                                                                                                            |
| `force-app/main/default/classes/`                    | Apex classes for authentication — `UIBundleAuthUtils`, `UIBundleChangePassword`, `UIBundleForgotPassword`, `UIBundleLogin`, `UIBundleRegistration` |
| `force-app/main/default/digitalExperienceConfigs/`   | Experience Cloud site configuration                                                                                                                |
| `force-app/main/default/digitalExperiences/`         | Experience Cloud site definition                                                                                                                   |
| `force-app/main/default/networks/`                   | Experience Cloud network                                                                                                                           |
| `force-app/main/default/sites/`                      | Salesforce site                                                                                                                                    |

## Getting started

Navigate to the UI Bundle and install dependencies:

```bash
cd force-app/main/default/uiBundles/reactexternalapp
npm install
npm run dev
```

Opens at http://localhost:5173 by default. For build and test instructions, see the [UI Bundle README](force-app/main/default/uiBundles/reactexternalapp/README.md).

## Deploy

### Deploy everything (metadata + Experience Cloud site + UI Bundle)

```bash
cd force-app/main/default/uiBundles/reactexternalapp && npm install && npm run build && cd -
sf project deploy start --source-dir force-app --target-org <alias>
```

### Deploy the UI Bundle only

```bash
cd force-app/main/default/uiBundles/reactexternalapp && npm install && npm run build && cd -
sf project deploy start --source-dir force-app/main/default/ui-bundles --target-org <alias>
```

### Deploy Experience Cloud site only

```bash
sf project deploy start \
  --source-dir force-app/main/default/digitalExperienceConfigs \
  --source-dir force-app/main/default/digitalExperiences \
  --source-dir force-app/main/default/networks \
  --source-dir force-app/main/default/sites \
  --target-org <alias>
```

### Deploy authentication classes only

```bash
sf project deploy start --source-dir force-app/main/default/classes --target-org <alias>
```

Replace `<alias>` with your target org alias.

## Configure Your Salesforce DX Project

The `sfdx-project.json` file contains useful configuration information for your project. See [Salesforce DX Project Configuration](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm) in the _Salesforce DX Developer Guide_ for details about this file.

## Read All About It

- [Salesforce Extensions Documentation](https://developer.salesforce.com/tools/vscode/)
- [Salesforce CLI Setup Guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm)
- [Salesforce DX Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_intro.htm)
- [Salesforce CLI Command Reference](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference.htm)
