Skip to content

Add support for Next.js #251

Open
@dcramer

Description

Our existing example snippets don't work great out of the box for Next.js. This is a collection of notes/feedback around that, which may need a new approach to embedding, or simply first-class docs.

per @Shubhdeep12 on Discord

If we go by the docs and use sentry/next sdk, its very simple. After adding Sentry/nextjs there's a file created sentry.client.config.ts which initializes the sentry for client. Adding spotlight init in that file makes sense and will not cause any issue and will not require any checks. Reference - https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/

import '@/styles/globals.css'
import type { AppProps } from 'next/app'
import * as Spotlight from '@spotlightjs/spotlight'

export default function App({ Component, pageProps }: AppProps) {
  return <Component {...pageProps} />
}

if (typeof window !== 'undefined' && process.env.NODE_ENV !== 'production') {
  Spotlight.init()
}

My hunch aligns with suggesting Sentry's core installation method then bundle Spotlight into sentry.client.config.ts.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions