Saving static HTML page generated with ReactJS

Viewed 814

Background:

I need to allow users to create web pages for various products, with each page having a standard overall appearance. So basically, I will have a template, and based on the input data I need the HTML page to be generated for each product. The input data will be submitted via a web form, following which the data should be merged with the template to produce the output.

I initially considered using a pure templating approach such as Nunjucks, but moved to ReactJS as I have prior experience with the latter.

Problem:

Once I display the output page (by adding the user input to the template file with placeholders), I am getting the desired output page displayed in the browser. But how can I now obtain the HTML code for this specific page?

When I tried to view the source code of the page, I see the contents of 'public/index.html' stating:

This HTML file is a template. If you open it directly in the browser, you will see an empty page.

Expectedly, the same happens when I try to save (Save As...) the html page via the browser. I understand why the above happens.

But I cannot find a solution to my requirement. Can anyone tell me how I can download/save the static source code for the output page displayed on the browser.

I have read possible solutions such as installing 'React/Redux Development Extension' etc... but these would not work as a solution for external users (who cannot be expected to install these extensions to use my tool). I need a way to do this on production environment.

p.s. Having read the "background" info of my task, do let me know if you can think of any better ways of approaching this.

Edit note: My app is currently actually just a single page, that accepts user data via a form and displays the output (in a full screen dialog). I don't wish to have these output pages 'published' on the website, and these are simply to be saved/downloaded for internal use. So simply being able to get the "source code" for the dislayed view/page on the browser and saving this to a file would solve my problem. But I am not sure if there is a way to do this?

3 Answers

If I'm understanding correctly, you need to generate a new page link for each user. Each of your users will have their own link (http/https) to share with their users.

For example, a scheduling tool will need each user to create their own "booking page", which is a generated link (could be on your domain --> www.yourdomain.com/bookinguser1).

You'll need user profiles to store each user's custom page, a database, and such. If you're not comfortable, I'll use something like an e-commerce tool that will do it for you.

You can turn on the debugger (f12) and go to "Elements"

Then right-click on the HTML tag and press edit as HTML

And then copy everything (ctrl + a)

enter image description here

Related