Skip to content
Discussion options

You must be logged in to vote

Btw, you can append stuff to globalThis, the problem is typically more with singletons, but if you did something like:

// my module
// global-vars.ts
const globalData = { data: 1000}

export default globalData

And then in instrumentation:

// import globalData
// inside the register function
globalThis.data = globalData

And then in your server component, you can do console.log(globalThis.data) and there'll be data, but doing this:

// import globalData
console.log(globalThis.data === globalData) // false - not the same singleton
console.log(globalThis.data.data, globalData.data) // 1000 1000

I wouldn't rely this too much though. Middleware will also see the value. You can segment out by pro…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@MansourM61
Comment options

@MansourM61
Comment options

@icyJoseph
Comment options

Answer selected by MansourM61
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants