Best Practices
Tips to guarantee a good user experience for your extensions.
General
Handle errors
Network requests can fail, permissions to files can be missing… More generally, errors happen. By default, we handle every unhandled exception or unresolved Promise and show error screens. However, you should handle the "expected" error cases for your command. You should aim not to disrupt the user's flow just because something went wrong. For example, if a network request fails but you can read the cache, show the cache. A user might not need the fresh data straight away. In most cases, it's best to show a Toast
with information about the error.
Here is an example of how to show a toast for an error:
Handle runtime dependencies
Ideally, your extension doesn't depend on any runtime dependencies. In reality, sometimes locally installed apps or CLIs are required to perform functionality. Here are a few tips to guarantee a good user experience:
If a command requires a runtime dependency to run (e.g. an app that needs to be installed by the user), show a helpful message.
If your extension is tightly coupled to an app, f.e. searching tabs in Safari or using AppleScript to control Spotify, checks don't always have to be strict because users most likely don't install the extension without having the dependency installed locally.
If only some functionality of your extension requires the runtime dependency, consider making this functionality only available if the dependency is installed. Typically, this is the best case for actions, e.g. to open a URL in the desktop app instead of the browser.
Show loading indicator
When commands need to load big data sets, it's best to inform the user about this. To keep your command snappy, it's important to render a React component as quickly as possible.
You can start with an empty list or a static form and then load the data to fill the view. To make the user aware of the loading process, you can use the isLoading
prop on all top-level components, e.g. <Detail>
, <Form>
, <Grid>
, or <List>
.
Here is an example to show the loading indicator in a list:
Forms
Use Forms Validation
When an end-user enters some data, you can check to see that this input is in a format you expect. If the data isn't correctly formatted, you can set the error
prop on the Form item to show a message explaining what needs to be corrected, and lets them try again.
Keep in mind that if the Form has any errors the Action.SubmitForm
onSubmit
callback won't be triggered.
Last updated