DEV Community

Cover image for Top 10 npm Packages You Can't Afford to Miss as a Developer
Sufian mustafa
Sufian mustafa

Posted on

Top 10 npm Packages You Can't Afford to Miss as a Developer

Introduction❤️‍🔥

In the dynamic world of web development, incorporating third-party libraries can significantly boost your productivity and add engaging features to your React applications. In this blog post, we'll explore the usage of ten npm packages that bring animation, styling, multimedia, and more to your React projects.

Top 10 npm Packages

1. Animate.css▶️

Animate.css is a powerful library for adding CSS animations to your elements with minimal effort.

Installation

npm install animate.css

Enter fullscreen mode Exit fullscreen mode

Usage

import 'animate.css';
const AnimatedComponent = () => (
  <div className="animate__animated animate__fadeIn">
    This content fades in!
  </div>
);

Enter fullscreen mode Exit fullscreen mode

2. AOS (Animate On Scroll) 😉

AOS is a library that animates elements as they scroll into view.

Installation

npm install aos
Enter fullscreen mode Exit fullscreen mode

Usage

import AOS from 'aos';
import 'aos/dist/aos.css';

const ScrollAnimatedComponent = () => {
  useEffect(() => {
    AOS.init();
  }, []);

  return (
    <div data-aos="fade-up">
      This content fades in as you scroll!
    </div>
  );
};
Enter fullscreen mode Exit fullscreen mode

3. Framer Motion 😍

Introduction
Framer Motion simplifies animation and gesture handling in React applications.

npm install framer-motion
Enter fullscreen mode Exit fullscreen mode

Usage

import { motion } from 'framer-motion';

const MotionComponent = () => (
  <motion.div animate={{ scale: 1.5 }} transition={{ duration: 1 }}>
    This content scales on load!
  </motion.div>
);
Enter fullscreen mode Exit fullscreen mode

4.react-circular-progressbar: 🟢

Visualize progress effectively with react-circular-progressbar, a React component that renders customizable circular progress bars. Its intuitive API and diverse customization options make it an ideal choice for displaying progress indicators in your applications.

Install & Usage

npm install react-circular-progressbar

import { CircularProgressbar, buildStyles } from 'react-circular-progressbar';
import 'react-circular-progressbar/dist/styles.css';

const CircularProgressBarComponent = () => {
  const percentage = 50;

  return <CircularProgressbar value={percentage} styles={buildStyles({ pathColor: '#3E98C7' })} />;
};

Enter fullscreen mode Exit fullscreen mode

5.react-html5video: ▶️

Integrate HTML5 videos into your React applications seamlessly with react-html5video, a lightweight library that provides a React component for managing video playback. It handles common video playback functionalities, such as play, pause, seek, and fullscreen mode.

Install & Usage

npm install react-html5video

import { Video } from 'react-html5video';
import 'react-html5video/dist/styles.css';

const VideoComponent = () => {
  return <Video controls={['PlayPause', 'Seek', 'Time', 'Volume', 'Fullscreen']} />;
};
Enter fullscreen mode Exit fullscreen mode

6.react-image-lightbox: 📷

Enhance image viewing with react-image-lightbox, a React library that creates responsive and customizable image lightboxes. It provides a sleek and user-friendly interface for displaying images in a modal-like overlay, allowing users to zoom in, navigate between images, and view image details.

Install & Usage

npm install react-image-lightbox

import Lightbox from 'react-image-lightbox';
import 'react-image-lightbox/style.css';
const ImageLightboxComponent = () => {
  const images = ['/image1.jpg', '/image2.jpg'];
  const [photoIndex, setPhotoIndex] = useState(0);

  return (
    <Lightbox
      mainSrc={images[photoIndex]}
      nextSrc={images[(photoIndex + 1) % images.length]}
      prevSrc={images[(photoIndex + images.length - 1) % images.length]}
      onCloseRequest={() => setPhotoIndex(0)}
      onMovePrevRequest={() => setPhotoIndex((photoIndex + images.length - 1) % images.length)}
      onMoveNextRequest={() => setPhotoIndex((photoIndex + 1) % images.length)}
    />
  );
};
Enter fullscreen mode Exit fullscreen mode

7. react-helmet: 🤑

Manage essential meta tags and document head information effortlessly with react-helmet. This library seamlessly integrates with React components, allowing you to define and update meta tags, title tags, and link tags directly within your components.

Install & Usage

npm install react-helmet

import { Helmet } from 'react-helmet';

const HelmetComponent = () => {
  return (
    <Helmet>
      <title>My React App</title>
      <meta name="description" content="A fantastic React application." />
    </Helmet>
  );
};

Enter fullscreen mode Exit fullscreen mode

8. react-infinite-scroll-component: 📜

Implement infinite scrolling capabilities with react-infinite-scroll-component, a React library that handles loading additional content as the user scrolls down the page. It simplifies pagination and provides a smooth user experience when loading large datasets.

Install & Usage

npm install react-infinite-scroll-component

import InfiniteScroll from 'react-infinite-scroll-component';

const InfiniteScrollComponent = () => {
  const fetchData = () => {
    // Fetch and append more data to your component
  };

  return (
    <InfiniteScroll
      dataLength={/* Length of your data array */}
      next={fetchData}
      hasMore={/* Boolean indicating whether more data is available */}
      loader={<h4>Loading...</h4>}
    >
      {/* Render your data here */}
    </InfiniteScroll>
  );
};
Enter fullscreen mode Exit fullscreen mode

9. react-lazy-load-image-component: 🦥

Optimize image loading and performance with react-lazy-load-image-component, a React library that dynamically loads images based on their proximity to the viewport. It defers image loading until the user scrolls closer, reducing initial page load times and improving overall performance.

Install & Usage

npm install react-lazy-load-image-component

import { LazyLoadImage } from 'react-lazy-load-image-component';
import 'react-lazy-load-image-component/src/effects/blur.css';

const LazyLoadImageComponent = () => {
  return <LazyLoadImage src="image.jpg" alt="Lazy Loaded Image" effect="blur" />;
};
Enter fullscreen mode Exit fullscreen mode

10. React-Rotating-Text 🪰

Adding dynamic and attention-grabbing text to your React application is easy with React-Rotating-Text. This package allows you to create rotating text animations, perfect for showcasing key features or headlines.

Install & Usage

npm install react-rotating-text

import RotatingText from 'react-rotating-text';

const RotatingTextComponent = () => {
  const textArray = ['Welcome!', 'Explore', 'Innovate'];

  return <RotatingText items={textArray} />;
};

Enter fullscreen mode Exit fullscreen mode

Conclusion 🥰

And there you have it! A journey through some fantastic npm packages that can breathe life into your React projects. Thanks for taking the time to explore these tools with us! Remember, the world of web development is vast, and there's always something new to discover.

If you found this guide helpful give it a hearty 💖 and if you have any thoughts to share plz comments 💬 below 👇🏽
Your feedback keeps the community vibrant and encourages others on their coding adventures.

Happy coding, fellow developers! 🚀 Thanks for reading! 🫡

Top comments (0)