How to add Media Downloader in Next.js ?
In this article, we are going to learn how we can add Media Downloader in NextJs. NextJS is a React-based framework. It has the power to Develop beautiful Web applications for different platforms like Windows, Linux, and mac. The linking of dynamic paths helps in rendering your NextJS components conditionally.
Approach: To add our Media Downloader we are going to use the react-use-downloader package. The react-use-downloader package helps us to add testimonials anywhere in our app. So first, we will install the react-use-downloader package and then we will add the Media Downloader on our homepage.
Create NextJS Application: You can create a new NextJs project using the below command:
npx create-next-app gfg
Install the required package: Now we will install the react-use-downloader package using the below command:
npm i react-use-downloader
Project Structure: It will look like this.
Adding the Media Downloader: We can easily add the media downloader in our app after installing the react-use-downloader package. For this example, we are going to add the media downloader to our homepage.
Add the below content in the index.js file:
Explanation: In the above example first, we are importing the useDownloader component from the installed package. After that, we are adding our File and file names. Then we are adding a Progress bar, start downloading, and stop downloading buttons.
Steps to run the application: Run the below command in the terminal to run the app
npm run dev