nRF Connect for Desktop

Developer documentation

Logo

Basics

API

Misc


NordicSemiconductor/pc-nrfconnect-docs on GitHub

API reference

Minimal app

When developing an app for nRF Connect for Desktop, the minimal requirements are that you create a JavaScript package with these two things:

  1. A package.json with the needed properties.
  2. The entry point of your package must expose a React component as default export.

This alone would be sufficient for the launcher to display and start your app.

Normal app

While you could start with the mentioned minimal app and build the rest from scratch, it will be easier to use the prepared components from pc-nrfconnect-shared as it is demonstrated in pc-nrfconnect-boilerplate and pc-nrfconnect-rssi.

In the following sections the main building blocks from pc-nrfconnect-shared are explained:

Component: App

Example use in pc-nrfconnect-rssi.

Most apps will use the App component to create their main export. Visible to the user it provides the general app look and feel:

For developer it provides a scaffolding to place their own components and a prepared Redux store, which includes state and actions for the shared components (note that you cannot easily use the Redux store when creating the App element, as the store will be created and provided by the App component. But you can use it about everywhere else, usually through React Redux using either hooks or the connect function.)

Properties

Component: DeviceSelector

Example use in pc-nrfconnect-rssi.

Most apps want to present a device selector to the users and this component is the easiest way to achieve that. Configure it appropriately for the app and then pass it to the deviceSelect property of the App component.

Properties

Logging: logger

Example use in pc-nrfconnect-rssi.

A logger using winston, which apps can use to add log messages to the log below the main view.

Component: Slider

Example use in pc-nrfconnect-rssi.

A slider component, especially useful for configurations in the side panel. This slider supports a single or also multiple values, which is especially helpful if users can select a range.

Properties

Component: ConfirmationDialog

Example use in pc-nrfconnect-launcher.

A component to show a simple confirmation dialog.

Properties

Function: getAppFile

Example use in pc-nrfconnect-rssi.

Use this function if the app needs to access a file bundled with it. Remember to include these files in the files configuration of the app.

Display an error message

If you want to display an error message in an app, you can dispatch the action from the action creator showDialog from the ErrorDialogActions: Example use in pc-nrfconnect-rssi.

You can also specify a second parameter, which lists possible error resolutions, from which the users may choose one when being displayed the error: Example use in pc-nrfconnect-rssi.