Manoj Singh
Manoj Singh

Reputation: 2941

How to detect if the consuming application is running next js?

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

Answers (2)

SST
SST

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

Jonathan Dsouza
Jonathan Dsouza

Reputation: 608

You can use the window object to figure this out.

enter image description here

Hope this helps,

Cheers!

Upvotes: 2

Related Questions