Git Product home page Git Product logo

nextjs-with-honeybadger's Introduction

Next.js with Honeybadger Error Reporting

This is a simple example showing how to use Honeybadger to catch & report errors on both client + server side.

  • _app.js renders on both the server and client. It initializes Honeybadger to catch any unhandled exceptions
  • _error.js is rendered by Next.js while handling certain types of exceptions for you. It is overridden so those exceptions can be passed along to Honeybadger
  • next.config.js enables source maps in production and uploads them to Honeybadger

Getting Started

Execute create-next-app with npm or Yarn to bootstrap the example:

npm init next-app --example https://github.com/honeybadger-io/nextjs-with-honeybadger nextjs-with-honeybadger
# or
yarn create next-app --example https://github.com/honeybadger-io/nextjs-with-honeybadger nextjs-with-honeybadger

Next, copy the .env.local.example file in this directory to .env.local (which will be ignored by Git):

cd nextjs-with-honeybadger
cp .env.local.example .env.local

Open the .env.local and set your HONEYBADGER_API_KEY from your Honeybadger project settings page.

Note: Errors are not reported in development mode by default. To enable reporting in development, see the reportData option in _app.js.

Finally, install it and run:

NPM

npm install
npm run dev

Yarn

yarn
yarn dev

Your app should be up and running on http://localhost:3000! If it doesn't work, email us at [email protected].

Deployment

Deploy to Vercel:

Deploy with Vercel

You must add the following configuration values when deploying:

  • HONEYBADGER_API_KEY - The API key from your project settings page in Honeybadger.
  • HONEYBADGER_ASSETS_URL - Required by honeybadger-webpack to upload source maps to Honeybadger. Replace the [your app name] with the name of your Vercel project: https://[your app name].vercel.app/_next

Notes

  • By default, neither sourcemaps nor error tracking is enabled in development mode (see Configuration).

  • When enabled in development mode, error handling works differently than in production as _error.js is never actually called.

  • The build output will contain warning about unhandled Promise rejections. This caused by the test pages, and is expected.

  • The version of @zeit/next-source-maps (0.0.4-canary.1) is important and must be specified since it is not yet the default. Otherwise source maps will not be generated for the server.

  • Both @zeit/next-source-maps and @honeybadger-io/webpack are added to dependencies (rather than devDependencies) is because if used with SSR (ex. heroku), these plugins are used during production for generating the source-maps and sending them to Honeybadger.

  • See the Honeybadger webpack plugin docs and the Using Source Maps guide for more info about source map upload.

  • See the honeybadger.js user documentation for usage guides and more.

nextjs-with-honeybadger's People

Contributors

joshuap avatar konnorrogers avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.