I was unable to use "firebese app check" in a Next.js 13.4 project with the "app" directory in development mode. I tried using ReactFire, but I only encountered errors. The latest version of Next.js is in SSR, so I attempted to use effects to access the window object, but that didn't work either. I couldn't find any help online, including Chat GPT. Please could you help me with this issue.
I would like to use firebase appcheck within Nextjs (13.4 app directory) in dev mode.
There are two things you need to do in order to get it working.
The First is to ensure that the app check initialization is happening on the client. You can encapsulate the initialization in a component with the "use client" directive (I have a providers.tsx to do this sort of thing) and then further encapsulate it in a useEffect with empty dependency array to ensure it is only ran once.
Next, is to ensure that the FIREBASE_APPCHECK_DEBUG_TOKEN attribute is available on the windows namespace.
I will show my entire
providers.tsxso that you have context as to where this is being ran in the tree:And this is how
Providersis being used in theRoot Layout: