spotlight icon indicating copy to clipboard operation
spotlight copied to clipboard

Add support for Next.js

Open dcramer opened this issue 2 years ago • 2 comments

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.

dcramer avatar Dec 07 '23 18:12 dcramer

Ref #273

dcramer avatar Dec 14 '23 18:12 dcramer

Related: #987

BYK avatar Oct 06 '25 14:10 BYK