Install the JavaScript SDK and React module. This enables easy integration with your React application.

npm install


To configure Polaris, add the Polaris provider to your React application. Be sure to replace the apiKey and apiUrl with the values provided by Polaris for your application.

  <Outlet />

useInstrument() Hook

The useInstrument() hook provides a reference to an instrument that is determined by the name of the event. Let's take a look.

const instrument = useInstrument('unique-event-name');

The useInstrument() hook returns a reference the Instrument object for the event name provided.

The Instrument object has the following methods:

  • start() - Starts the measurement.
  • done() - Completes the measurement.
  • fail() - Fails the measurement.

Create a Measurement

We recommend instrumenting your application to measure critical workflows and system operations. Here is an example of creating a new measurement for a form submission.

  import { userInstrument } from '';

  export default function() {
    // first, create a new measurement
    const instrument = useInstrument('my-event')

    const handleSubmit = useCallback(async (values) => {
      try {
        await save(values);
        // then, complete the measurement using the `done()` method
      } catch (error) {
        // or, fail the measurement using the `fail()` method{ error });
    }, []);

    return (