As a library author, I'd like to know whether my library is being used with React or with some other UI framework (Vue, Svelte, ...).
Is there a way to detect whether React's code was loaded?
The following Stack Overflow answers don't answer this question because they only work using the developer console. (Whereas I want to detect React from the perspective of a JavaScript library.)
- How to tell if a web application is using ReactJs
- How can I detect if a website is built with React?
Context: I'm building vite-plugin-ssr. (It's like Next.js/Nuxt but as a do-one-thing-do-it-well Vite plugin.)
EDIT: I need to be able to detect React as soon as React is loaded in the browser, before React even renders/hydrates the page. So far, all answers below are detecting React too late.