Next.js

The following is an example of how to use monitro with next.js, this is a simple example and not the best way to use monitro, but it should give you an idea of how to use it.

//page.tsx
import { monitroClient } from'.../server.ts'

exportdefaultfunctionPage({ data }) {
// Render data...
}

exportasyncfunctiongetServerSideProps() {
// Fetch data from external API
constres=awaitfetch(`https://.../data`).catch((e) => {
monitroClient.error('Failed To Get API Data', 'failed to get api data', { error:e })
  })

// Pass data to the page via props
return { props: { res } }
}

server.ts

//server.ts
import { Monitro } from'monitro'

exportconstmonitroClient=newMonitro('monitro-dev', API_KEY, { hookExceptions:true });

// this can be any file in your project, but just make it accessible to all your server functions
Monitro's cleint can be used anywhere in next.js but keep it on the server side, you can use this on the clients browser but it is NOT recomended but currently the API key has no protection to abuse, we plan on adding this in the future.
On this page