# Best practices variables

**URL:** <https://community.weweb.io/t/best-practices-variables/8450>\
**Category:** Tips and Hacks\
**Tags:** binding\
**Created:** [May 4, 2024, 12:40pm UTC](https://community.weweb.io/t/best-practices-variables/8450 "2024-05-04T12:40:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![FHEXL](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/fhexl/32/13607_2.png) [@FHEXL](https://community.weweb.io/u/FHEXL)\
**Post date:** [May 4, 2024, 12:40pm UTC](https://community.weweb.io/t/best-practices-variables/8450/1 "2024-05-04T12:40:54Z")

</div>

Hi there,

During development I noticed that the number of variables can grow quite fast. I am taking more and more the approach to reuse variables as much as possible. This because as I understand a variable lives in the context of session. So I use for example:

modalOpened: boolean - to use for each modal (that is used on a different page). When using tabs and having multiple modals ons a page I am thinking to add current tab to the visibility conditions of the modal.

SelectedObject: {} (empty object). I use this to bind the data of a whole object. To use on modal forms.

How do you all efficiently and securely use variables in Weweb and are the common best practices te follow?

---

<div class="post-metadata">

**Author:** ![Doc](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/doc/32/8594_2.png) [@Doc](https://community.weweb.io/u/Doc)\
**Post date:** [May 9, 2024, 3:50am UTC](https://community.weweb.io/t/best-practices-variables/8450/2 "2024-05-09T03:50:55Z")

</div>

Great question!  
We mentioned possible solutions [here in the Office Hours](https://youtu.be/p_Q9IVDZFKY?si=ddQEObixpWYgjCk5).

Hope that helps take care!

---

<div class="post-metadata">

**Author:** ![Corner](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@Corner](https://community.weweb.io/u/Corner)\
**Post date:** [May 9, 2024, 7:23am UTC](https://community.weweb.io/t/best-practices-variables/8450/3 "2024-05-09T07:23:53Z")

</div>

Hello Doc, are you sure that this is the good link haha ? I’m getting this on click

 ![Capture d'écran 2024-05-09 092326](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/2/2fb8023d0035609da2851d5cf345953c46f15c60.png)  
Thanks

---

<div class="post-metadata">

**Author:** ![imb](https://avatars.discourse-cdn.com/v4/letter/i/ecd19e/32.png) [@imb](https://community.weweb.io/u/imb)\
**Post date:** [May 9, 2024, 9:27am UTC](https://community.weweb.io/t/best-practices-variables/8450/4 "2024-05-09T09:27:11Z")

</div>

yeah looking for this same info and the current link is not working

---

<div class="post-metadata">

**Author:** ![Doc](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/doc/32/8594_2.png) [@Doc](https://community.weweb.io/u/Doc)\
**Post date:** [May 11, 2024, 5:45am UTC](https://community.weweb.io/t/best-practices-variables/8450/5 "2024-05-11T05:45:20Z")

</div>

Whoops sorry about that! 😄 [Let’s try this again here is the correct link](https://youtu.be/p_Q9IVDZFKY?si=ddQEObixpWYgjCk5).

Thank you for your patience!

---

<div class="post-metadata">

**Author:** ![imb](https://avatars.discourse-cdn.com/v4/letter/i/ecd19e/32.png) [@imb](https://community.weweb.io/u/imb)\
**Post date:** [May 12, 2024, 9:13am UTC](https://community.weweb.io/t/best-practices-variables/8450/6 "2024-05-12T09:13:00Z")

</div>

Awesome so use objects whenever you can. Darn wish i new that sooner haha. it makes alot of sense.

“site settings can be an object. user variables can be a user object etc. group similar variables into an object. so at the minimum they’re easier to manage”
