README.md 1.7 KB
Newer Older
1 2 3 4 5 6
[![Deploy to now](https://deploy.now.sh/static/button.svg)](https://deploy.now.sh/?repo=https://github.com/zeit/next.js/tree/master/examples/with-sentry)

# Sentry example

## How to use

7 8
### Using `create-next-app`

9
Execute [`create-next-app`](https://github.com/segmentio/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:
10

11 12 13 14
```bash
npx create-next-app --example with-sentry with-sentry-app
# or
yarn create next-app --example with-sentry with-sentry-app
15 16 17 18
```

### Download manually

19
Download the example:
20 21 22 23 24 25 26

Install it and run:

**npm**
```bash
npm install
npm run dev
27 28 29
# or
yarn
yarn dev
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
```

**yarn**
```bash
npm install
npm run dev
```

Deploy it to the cloud with [now](https://zeit.co/now) ([download](https://zeit.co/download))

```bash
now
```

## About example

46
An example showing use of [Sentry](https://sentry.io) to catch & report errors on both client + server side.
47

48
### Configuration
49

50 51 52
You will need a _Sentry DSN_ for your project. You can get it from the Settings of your Project, in **Client Keys (DSN)**, and copy the string labeled **DSN (Public)**.

The Sentry DSN should then be added as an environment variable when running the `dev`, `build`, and `start` scripts in `package.json`:
53 54

```bash
55 56 57 58 59 60 61
{
  "scripts": {
    "dev": "SENTRY_DSN=<dsn> node server.js",
    "build": "SENTRY_DSN=<dsn> next build",
    "start": "SENTRY_DSN=<dsn> NODE_ENV=production node server.js"
  }
}
62 63
```

64
_Note: Setting environment variables in a `package.json` is not secure, it is done here only for demo purposes. See the [`with-dotenv`](../with-dotenv) example for an example of how to set environment variables safely._