Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/grafana-cloud/monitor-applications/frontend-observability/instrument/faro-react/v6-no-data-router.md, or by sending Accept: text/markdown to https://grafana.com/docs/grafana-cloud/monitor-applications/frontend-observability/instrument/faro-react/v6-no-data-router/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
Set up React Router v6 with no data router
Follow these steps to get started quickly with the Faro-React Web SDK for React Router v6 with no data router.
- Install the Faro-React Web SDK
- Instrument your application
Install the Faro-React Web SDK
First add Faro-React to your project. Install the Faro-React package by running the following command for NPM:
# install globally
npm i @grafana/faro-reactOr the following command Yarn:
yarn add @grafana/faro-reactInstrument your application
React Router v6
In the file you define your router, import createRoutesFromChildren, matchRoutes, Routes, useLocation, useNavigationType from react-router-dom and pass them to the dependencies object.
The final result should look similar like this example.
import { createRoutesFromChildren, matchRoutes, Routes, useLocation, useNavigationType } from 'react-router-dom';
import {
createReactRouterV6Options,
getWebInstrumentations,
initializeFaro,
ReactIntegration,
ReactRouterVersion,
} from '@grafana/faro-react';
initializeFaro({
// Mandatory, the URL of the Grafana collector
url: 'my/collector/url',
// Mandatory, the identification label of your application
app: {
name: 'my-react-app',
},
// ...
instrumentations: [
// Load the default Web instrumentations
...getWebInstrumentations(),
new ReactIntegration({
router: createReactRouterV6Options({
createRoutesFromChildren,
matchRoutes,
Routes,
useLocation,
useNavigationType,
}),
}),
],
});To instrument React Router v6 import the <FaroRoutes/> component and use it instead of the React router <Routes /> component, for example:
import { FaroRoutes } from '@grafana/faro-react';
// during render
<FaroRoutes>
<Route path="/" element={<Home />} />
{/* ... */}
</FaroRoutes>;Next
Refer to the JavaScript quickstart documentation for instructions on how to create and send data to a Grafana Cloud Frontend Application.
Was this page helpful?
Related resources from Grafana Labs


