Reputation: 2941
I am building a component library which can be used in vanilla react or next js applications.
When a component is installed, how can I detect if the component is being used in next js context?
Upvotes: 0
Views: 964
Reputation: 1
Apart from Window.next, you can also search for "__next" in HTML source using Inspect element. Next apps have this div in their app so if you can see that that means its on NEXTJS.
Upvotes: 0
Reputation: 608
You can use the window object to figure this out.
Hope this helps,
Cheers!
Upvotes: 2