# Keeping state of a Page and its components between Page refreshes or Posts

**URL:** <https://discuss.emberjs.com/t/keeping-state-of-a-page-and-its-components-between-page-refreshes-or-posts/18640>\
**Category:** Uncategorized\
**Created:** [February 21, 2021, 10:16pm UTC](https://discuss.emberjs.com/t/keeping-state-of-a-page-and-its-components-between-page-refreshes-or-posts/18640 "2021-02-21T22:16:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![abdul](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@abdul](https://discuss.emberjs.com/u/abdul)\
**Post date:** [February 21, 2021, 10:16pm UTC](https://discuss.emberjs.com/t/keeping-state-of-a-page-and-its-components-between-page-refreshes-or-posts/18640/1 "2021-02-21T22:16:52Z")

</div>

Hi I have Tab like design for my page which is created using UL and Div and loading the different partial components or hbs files when clicked.

Now the problem is when I post some data to Server then when the whole page refreshes or loads, then the selected tab is defaulting to the first Tab that I have, I want to save the tab that’s selected before I posted to server then when page data is refreshed I want to read from the state that’s saved and load that particular tab, can somebody please advice me. I have code but it’s huge, but if you insist to post here I can but need to delete a lot of it as its too huge.

Any suggestion please helps thank you so much

---

<div class="post-metadata">

**Author:** ![b-arto](https://avatars.discourse-cdn.com/v4/letter/b/eb8c5e/32.png) [@b-arto](https://discuss.emberjs.com/u/b-arto)\
**Post date:** [February 22, 2021, 7:25pm UTC](https://discuss.emberjs.com/t/keeping-state-of-a-page-and-its-components-between-page-refreshes-or-posts/18640/2 "2021-02-22T19:25:46Z")

</div>

Hi, the first thing that comes to my mind is trying to create proper data model on back-end site, that contains info about current tab e.g. kind of flag.

---

<div class="post-metadata">

**Author:** ![dknutsen](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dknutsen/32/16471_2.png) [@dknutsen](https://discuss.emberjs.com/u/dknutsen)\
**Post date:** [February 22, 2021, 7:36pm UTC](https://discuss.emberjs.com/t/keeping-state-of-a-page-and-its-components-between-page-refreshes-or-posts/18640/3 "2021-02-22T19:36:36Z")

</div>

or depending on the data and how it’s fetched you could use a route for your tabs so the active tab becomes part of the URL and therefore persists on refresh

---

<div class="post-metadata">

**Author:** ![abdul](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@abdul](https://discuss.emberjs.com/u/abdul)\
**Post date:** [February 22, 2021, 10:06pm UTC](https://discuss.emberjs.com/t/keeping-state-of-a-page-and-its-components-between-page-refreshes-or-posts/18640/4 "2021-02-22T22:06:40Z")

</div>

OK I am doing it now but it seems like it has got performance hit, is there nothing like ViewState in Ember or JavaScript Technologies?

---

<div class="post-metadata">

**Author:** ![dknutsen](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dknutsen/32/16471_2.png) [@dknutsen](https://discuss.emberjs.com/u/dknutsen)\
**Post date:** [February 22, 2021, 10:27pm UTC](https://discuss.emberjs.com/t/keeping-state-of-a-page-and-its-components-between-page-refreshes-or-posts/18640/5 "2021-02-22T22:27:08Z")

</div>

Not built-in. IIRC ViewState requires server support and Ember is server agnostic so you’d have to write your own or use an addon for something like that.
