@lightspeed/react-new-relic-script
TypeScript icon, indicating that this package has built-in type declarations

0.1.16 • Public • Published

@lightspeed/react-new-relic-script

npm version

Introduction

In serverside rendered React apps, this component renders to the browser timing header for clientside New Relic instrumentation.

Quick Start

  1. Install the dependency in your webapp.
yarn add newrelic @lightspeed/react-new-relic-script
  1. Configure New Relic by either creating a newrelic.js configuration file at the root directory of your webapp, or setting environment variables as described here. You will at least need to set the app_name and license_key configurations.

  2. Add require('newrelic'); as the first line of your application's entry point. Modules syncronously loaded New Relic will be instrumented appropriately.

  3. In your serverside rendered document component, render the <NewRelicScript /> component in the <head /> of your document. For example, in a Next.js app with serverside rendering, use the component as follows:

// app/_document.tsx
import React from 'react';
import Document, { Head, Main, NextScript, NextDocumentContext } from 'next/document';
import NewRelicScript from '@lightspeed/react-new-relic-script';

export default class MyDocument extends Document {
  render() {
    return (
      <html>
        <Head nonce={this.props.nonce}>
          <title>Lightspeed Retail - Cool Page</title>
          <NewRelicScript />
        </Head>
        <body>
          <Main />
          <NextScript />
        </body>
      </html>
    );
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @lightspeed/react-new-relic-script

Weekly Downloads

25

Version

0.1.16

License

MIT

Unpacked Size

6.54 kB

Total Files

6

Last publish

Collaborators

  • kurt.bergeron
  • lightspeedhq
  • ls-guillaume-lambert
  • ls-frederic-bouchard
  • anomen