Importing in your project
Inside a Node.js-based project
You can add the React component to your Node.js-based project (e.g. using Next.js or Vite) with:
npm install @frameright/react-image-display-control
Less than 5kB in your final client-side bundle.
No matter whether your code is intended to run in the browser, during server-side rendering or at build time for building static pages, you can import the React component anywhere with:
import '@frameright/react-image-display-control';
Inside a Next.js project
As a workaround for
"Module not found: Can't resolve 'fs' in Next.js application",
you need to set config.resolve.fallback = { fs: false };
in your
next.config.js
in order to be able to import the React component. Your file
should look like this:
next.config.js
module.exports = {
webpack: (config) => {
config.resolve.fallback = { fs: false };
return config;
},
};
Create it if it doesn't exist yet in your project.