-
SummaryI need to run some code server-side on app launch to do some initialization. I discovered the instrumentation feature which seemed to cover my use case. However, when I try to run code that access node.js libraries like
My instrumentation.ts looks like this:
Am I correct in saying that instrumentation.ts runs server-side so it should be able to access node.js libraries? If not, is there another way to run some initialization code on server launch? Additional informationNo response Example |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
I have resolved my issue (thanks to StackOverflow) but got very confused along the way. This code works fine:
However, this code does not.
Why???? |
Beta Was this translation helpful? Give feedback.
-
I'm also extremely Confused by this, the documentation for Instrumentation says that it is initialized once per Next.js server initialization - this seems to very much imply that it runs server-side. I don't know what use this can possibly be if it runs client side? |
Beta Was this translation helpful? Give feedback.
-
There are actually good reasons to have client-side instrumentation, but it seems we're caught in between, with instrumentation that only runs on the server but acts like it runs on the client |
Beta Was this translation helpful? Give feedback.
I have resolved my issue (thanks to StackOverflow) but got very confused along the way. This code works fine:
However, this code does not.
Why????