# Duplication of component and related variables at once

**URL:** <https://community.weweb.io/t/duplication-of-component-and-related-variables-at-once/10038>\
**Category:** How do I?\
**Created:** [July 31, 2024, 2:43pm UTC](https://community.weweb.io/t/duplication-of-component-and-related-variables-at-once/10038 "2024-07-31T14:43:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrii\_r](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@andrii\_r](https://community.weweb.io/u/andrii_r)\
**Post date:** [July 31, 2024, 2:43pm UTC](https://community.weweb.io/t/duplication-of-component-and-related-variables-at-once/10038/1 "2024-07-31T14:43:25Z")

</div>

Hi, I made an element for Autocomplete address from Google Places API:

 ![Снимок экрана 2024-07-31 в 17.31.26](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/8/8eb839ac64a5865180deca8939f05b6b60e15541.png)  
 ![Снимок экрана 2024-07-31 в 17.32.06](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/2/25fc8c1b4dba16ba3dfdfe96c88b34236ad9a989.png)  
 ![Снимок экрана 2024-07-31 в 17.32.41](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/f/ff8f3071f49a6fba82df9e0f67416ce7d9c48032.png)

This element uses a set of variables for its work, for init\_value in inputs and for workflow  
 ![Снимок экрана 2024-07-31 в 17.30.40](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/f/f5432da082ca94ab1a1e946e7098b90d68234ac2.png)

Now a question, I need to copy this component to all forms where it will be used (many forms). And in some forms there can be 5 such components in one form

Is it possible to do duplicate variables while duplicating the component?

If I just click duplicate, the component is duplicated, but the variables remain the same

 ![Снимок экрана 2024-07-31 в 17.41.28](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/7/743f967a388993890497e0733d849a65f0f7aba0.png)  
 ![Снимок экрана 2024-07-31 в 17.41.54](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/1/112c9fdf1a622f4ae7f90383aa808596ea2618ed.png)

What is the best solution for this, would I really have to manually create variables for each component and reassign them within the component and workflow?

---

<div class="post-metadata">

**Author:** ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)\
**Post date:** [August 1, 2024, 1:40pm UTC](https://community.weweb.io/t/duplication-of-component-and-related-variables-at-once/10038/2 "2024-08-01T13:40:17Z")

</div>

Hi @andrii_r 👋

The best solution for this is to use component variables. That way, the variables are scoped to each instance of the component.

Working with component variables can be a bit daunting at first but is very helpful to maintain and scale your project.

You can learn more about [component variables here](https://docs.weweb.io/components/intro-to-components.html#component-variables) and [here](https://academy.weweb.io/components/scope/).

I hope that helps!

---

<div class="post-metadata">

**Author:** ![andrii\_r](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@andrii\_r](https://community.weweb.io/u/andrii_r)\
**Post date:** [August 1, 2024, 11:41pm UTC](https://community.weweb.io/t/duplication-of-component-and-related-variables-at-once/10038/3 "2024-08-01T23:41:28Z")

</div>

Thank you, @Joyce, very helpful as always 🙂

---

<div class="post-metadata">

**Author:** ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)\
**Post date:** [August 2, 2024, 10:36am UTC](https://community.weweb.io/t/duplication-of-component-and-related-variables-at-once/10038/4 "2024-08-02T10:36:20Z")

</div>

Awesome! Glad I could help 🙂

---

<div class="post-metadata">

**Author:** ![andrii\_r](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@andrii\_r](https://community.weweb.io/u/andrii_r)\
**Post date:** [August 3, 2024, 9:32am UTC](https://community.weweb.io/t/duplication-of-component-and-related-variables-at-once/10038/5 "2024-08-03T09:32:44Z")

</div>

It works perfectly 🎉 🎉 🎉

![Снимок экрана 2024-08-03 в 12.29.56](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/1/1ec4ad015e467f8b28e96ef575d53fa0b79cf3e9.png)

 ![Снимок экрана 2024-08-03 в 12.31.04](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/d/dd80e88249a477157b3c406b9c33b27a73493fb6.png)
