'Create and download (html/css/js) files client-side

I've built a code playground (similar to liveweave) using react. the users can save their "code playgrounds" and access them later. (using firebase db) ,this "code playgrounds"are just made of HTML, CSS, and js. I´m trying to add a functionality which allow the user to download a playground, the idea is that it will generate 3 separate files (one for each language in the playground)

1) is there a way to generate (HTML CSS and js) files and populate them with content client-side?

2) if so, would there be any chance to group those files inside a .rar also client-side?

3) if generating these files client-side is not the optimal solution/not possible, how would you approach this problem?

I was thinking maybe in an express server that queries the data from the db and then response with those files, but I would like to try a client-sided solution



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source