Typesaurus works well with Next.js. It can be used both on the client and the server, including React Server Components.
Client-side
For the client and SSR, please see the React integration docs, as everything there applies to Next.js as well.
Server-side & RSC
It gets a bit trickier for the server-side and React Server Components.
To make it work, initialize and export the Firebase Admin SDK in a separate file. Then, you have to import it from your Next.js pages and API routes.
You’ll need to set GOOGLE_APPLICATION_CREDENTIALS_JSON environment variable to the Firebase Admin SDK credentials JSON. You can get it from the Firebase console. Follow instructions from official Firebase Admin SDK docs.
Also note that because of Next.js hot-reloading, the file is executed multiple times. That’s why we check if the SDK is already initialized.
For example, here we create a post on POST request (app/posts/route.ts):
And here we render the posts in a React Server Component (app/posts/page.tsx):
You can use the root layout to import the SDK, so you don’t have to do it in every page (app/layout.tsx):