How to prefill hubspot form fields using localStorage

In my reactjs frontend application all webforms are coming from Hubspot and I want to fill three fields:

1- Firstaname

2- Lastname

3- Email

with values which are in my local storage like below:

(key)firstName: value(abc)

(key)lastName: value(cde)

(key)Email: value(abc@test.com)

If I inspect my firstname field I see below:

SHussain5_0-1672159414845.png

These are the values of logged in user which I wan to prefill.

Can anyone please help me how I can prefill those 3 fields with values which are in my local Storage!

Your help will be appreciated!

Hi @SHussain5

Thank you for reaching out.

I want to tag some of our experts here - @JBeatty @albertsg @weiliang_lee do you have any thoughts for @SHussain5 on this?

Thank you!

Best

Tiphaine

I am still look for the solution, can anyone please help me? @TitiCuisset @JBeatty @albertsg @weiliang_lee

Below is code which is responsible for displaying all hubspot forms:

case “hubspot_form”:

if (paragraphEntity.entityRendered) {

returnElement = parseToReact(paragraphEntity.entityRendered);

}

break;

Hi @SHussain5 :

If you’re saying you store the user’s credentials in localStorage after they log in, then retrieve them using the localStorage.getItem(key) method, then pass it — again, to your controlled form (using the value attribute within the form itself).

If you find it helpful.Mark it as solution.

Thanks!

Hi, @GRajput :waving_hand: Thanks for adding your suggestion. Hey, @SHussain5 can you give this a try? Thank you! — Jaycee