Solution

To download a zip file in React, you can use the a anchor tag with download attribute. So if some one click on link browser will download the file.

Snippet

In this snippet, we will see sample code of anchor tag which will help you download the file.

<a href={this.state.zipUrl} download>
  Download zip
</a>

Example

In this example, we will create download link for downloading zip file in react js.

Let’s start coding…

import React from "react";

export default class MyComponent extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      zipUrl:
        "https://reactjssnippet.github.io/-reactjssnippet.images/cb_2017_02_tract_500k.zip"
    };
  }

  render() {
    return (
      <div>
        <a href={this.state.zipUrl} target="_blank">
          Download zip
        </a>
      </div>
    );
  }
}

codesandbox