We recommend that you build your local fulfillment app using the steps described
earlier, then test your smart home integration on your own hosting environment
using the following steps:

1. In your own hosting environment, serve the HTML page that runs your
   local fulfillment app. The following snippet shows an example of a static HTML file
   that runs your local fulfillment app.

   ```
   <html>
     <head>
       <!-- Local Home SDK -->
       <script src="//www.gstatic.com/eureka/smarthome/smarthome_sdk.js"></script>
       <!-- Local app under development -->
       <script src="local_execution.js"></script>
     </head>

   </html>
   ```
2. [Test device control](https://developers.home.google.com/local-home/test.md.txt#test_device_control).

3. [Debug from Chrome](https://developers.home.google.com/local-home/test.md.txt#debug_from_chrome). Use breakpoints and logs to
   troubleshoot your integration.

4. Modify and compile your TypeScript code, then repeat these steps.

By repeating this build-and-test process, you can see your changes in action
quickly to help you debug issues with your code.

## Test device control

In the [Google Home Developer Console](https://console.home.google.com), you need to
specify the URL of your web app, which
serves the HTML that gets loaded on the Google Home or Google Nest device during local fulfillment.

> [!NOTE]
> **Note:** In addition to manual testing, we strongly recommend that you test your smart home Action using the [Google Home Test Suite](https://developers.home.google.com/cloud-to-cloud/tools/test-suite.md.txt). Doing so helps to ensure that your Action supports all queries that are valid for your device type and traits.

To test device control with local fulfillment, follow these steps:

### Chrome

1. In the **Setup and configuration** page of your Cloud-to-cloud integration in the [Google Home Developer Console](https://console.home.google.com), scroll to **Local fulfillment** and toggle the setting on.
2. Under **Testing URLs** \> **Testing URL for Chrome**, specify the development server URL that serves the HTML that runs your local fulfillment app.
3. Click **Save**. It may take up to 30 minutes for Google to propagate your console changes.
4. Reboot your test Google Home or Google Nest device.
5. Issue a command to your smart device. For example, if your device implements the [OnOff](https://developers.home.google.com/cloud-to-cloud/traits/onoff.md.txt) trait, you could say "Hey Google, turn on the lights."

### Node.js

1. In the **Setup and configuration** page of the [Google Home Developer Console](https://console.home.google.com), scroll to **Local fulfillment** and toggle the setting on.
2. Under **Testing URLs** \> **Testing URL for Node**, specify the development server URL that serves the JavaScript that runs your local fulfillment app.
3. Click **Save**. It may take up to 30 minutes for Google to propagate your console changes.
4. Reboot your test Google Home or Google Nest device.
5. Issue a command to your smart device. For example, if your device implements the [OnOff](https://developers.home.google.com/cloud-to-cloud/traits/onoff.md.txt) trait, you could say "Hey Google, turn on the lights."

For more details on which runtime is used by your device, see [Supported
devices](https://developers.home.google.com/local-home/overview#supported-devices).

> [!NOTE]
> **Note:** You can force your test Google Home or Google Nest device to use a local fulfillment path with the command *"Hey Google, force local."* In this mode, intents will not fall back to cloud fulfillment if an error occurs. When you are done testing, you should reset your device to normal operation using the command *"Hey Google,
> force default."*

## Debug from Chrome

You can debug your local fulfillment app using [Chrome
DevTools](https://developers.google.com/web/tools/chrome-devtools/).
Before you can debug, make sure
that your environment is correctly set up:

- You have set your development URL in the console to a URL reachable by the Google Home or Google Nest device (either on the local area network or using the internet),
- Your machine is connected to the same local area network as the Google Home or Google Nest device you are testing.
- Your network doesn't block packets between devices.
- You are logged in with the same Google Account on the [Google Home Developer Console](https://console.home.google.com) and on the Google Home or Google Nest device.
- You have [updated the SYNC response in your cloud
  fulfillment](https://developers.home.google.com/local-home/device-discovery#update_sync_response_in_the_cloud_fulfillment). It should return at least one valid value in the `otherDeviceIds` field.
- You have entered the [correct scan config
  information](https://developers.home.google.com/local-home/device-discovery#set_up_the_scan_config_information) in the [Google Home Developer Console](https://console.home.google.com).

To connect your local fulfillment app to the Chrome DevTools debugger,
follow these steps:

### Chrome

1. In your local development machine, install and launch the [Google Chrome browser](https://www.google.com/chrome/).
2. In the address field of your Chrome browser, launch the Chrome inspector by entering: `chrome://inspect#devices`. You should see a list of devices on the page, and your HTML file should be listed under the name of your test Google Home or Google Nest device.
3. Click the blue inspect link under your HTML to launch Chrome DevTools. Switch to the **Console** tab. The Local Home platform outputs your app version and the Local Home SDK version in the console log. If you see the log, it means that Google has loaded your app successfully, and is able to connect to it. If not, reboot your Google Home or Google Nest device.
![](https://developers.home.google.com/static/local-home/images/chrome-inspect-local.png) Figure 1: Local fulfillment app in chrome://inspect.

### Node.js

1. In your local development machine, install and launch the [Google Chrome browser](https://www.google.com/chrome/).
2. Determine the local IP address of your test device.
3. In the address field of your Chrome browser, launch the Chrome inspector by entering: `chrome://inspect#devices`.
4. Select **Configure...** to open the **Target discovery settings**.
![](https://developers.home.google.com/static/local-home/images/target-discovery.png) Figure 2: Target discovery settings in chrome://inspect.
5. Enter `DEVICE_IP_ADDRESS:9222` in the list and click **Done**.
6. Click the blue inspect link under your script to launch Chrome DevTools. Switch to the **Console** tab. The Local Home platform outputs your app version and the Local Home SDK version in the console log. If you see the log, it means that Google has loaded your app successfully, and is able to connect to it. If not, reboot your Google Home or Google Nest device.

For more details on which runtime is used by your device, see [Supported
Devices](https://developers.home.google.com/local-home/overview#supported-devices).

## Debugging tips

Some additional things to keep in mind during debugging include:

- Don't link multiple Google Home or Google Nest devices to your test account on the same local network. You won't be able to control which Google Home or Google Nest device is targeted with the local fulfillment commands.
- Refresh the page in Chrome DevTools to reload your local fulfillment app container with the latest code from your development URL. This does not reset the Local Home platform, which may be necessary to re-trigger platform intents (such as `IDENTIFY`) in your local fulfillment app. To reset the Local Home platform, reboot your Google Home or Google Nest device.
- Check that your JavaScript app loads without errors. To do this, check the console section of the DevTools page. If there is a problem, you will see a message like this: 'Uncaught TypeError: Cannot read property 'open' of null.'
- The `verificationId` from the `IDENTIFY` response must match one of the `otherDeviceIds` from the `SYNC` response.
- For the `EXECUTE` handler, make sure your HTTP, TCP, or UDP commands can be received by your device and work as expected.
- Make sure to return a `Promise` from the handlers.
- Avoid maintaining global state in memory. See [Application lifecycle](https://developers.home.google.com/local-home/overview.md.txt#app-lifecycle).
- Errors thrown by your local fulfillment app will appear in your project [error logs](https://developers.home.google.com/cloud-to-cloud/analytics/logging.md.txt).

## Prepare and launch to production

When you are ready to launch your smart home Action, follow these steps:

1. Open a terminal. In your project directory, run the `npm run build` command. This command generates the following JavaScript bundles for your app under the `dist` directory:

   ```
   project-directory/
   └── dist
    ├── web
    │    └── bundle.js
    └── node
         └── bundle.js
   ```
2. In the **Setup and configuration** page of the [Google Home Developer Console](https://console.home.google.com), scroll to **Local fulfillment** and toggle the setting on.
3. Using the **Upload JavaScript** buttons, upload the bundle files that you previously generated. ![](https://developers.home.google.com/static/local-home/images/javascript-upload.png) Figure 3: Upload your JavaScript app. Make sure to upload both versions of the bundle files (Node, Web) so that your Action is configured to work correctly across all runtime environments that local fulfillment supports.
   1. **Upload your JavaScript targeting Node.js** : Upload the `bundle.js` file from the `dist/node` directory.
   2. **Upload your JavaScript targeting Chrome (browser)** : Upload the `bundle.js` file from the `dist/web` directory.
4. Test your Action on an Assistant-enabled device, to verify that it behaves as expected in a production environment. To learn more, see [Test and share your smart home Action](https://developers.home.google.com/cloud-to-cloud/test.md.txt).
5. When you are satisfied with how your Action works, submit it to Google for production deployment by following the instructions in [Launch your smart home Action](https://developers.home.google.com/cloud-to-cloud/launch/action). This includes completing the self-test and certification request steps.