How to Build a Custom Wishlist Drawer Using Browser LocalStorage

How to Build a Custom Wishlist Drawer Using Browser LocalStorage

A wishlist does not always require a Shopify app.

For stores that need a lightweight wishlist experience without customer accounts, external databases, or recurring app fees, browser localStorage can be enough.

A custom wishlist can be implemented entirely in the theme using Liquid, HTML, CSS, and JavaScript. The browser stores the selected products, while the Shopify theme is responsible for rendering and updating the interface.

This approach works particularly well for stores that want a simple wishlist drawer rather than a full account-based wishlist system.

How the Architecture Works

A basic implementation has four parts:

Product Card
    ↓
Add to Wishlist
    ↓
Browser LocalStorage
    ↓
Wishlist Drawer
    ↓
Product URLs

The wishlist does not need to store the complete Shopify product object.

Instead, it can store a small amount of information such as:

[
  {
    "id": 123456789,
    "handle": "example-product"
  }
]

The important part is keeping the stored data small and predictable.

Why Use LocalStorage?

localStorage provides persistent browser storage.

Unlike a JavaScript variable, data stored there survives page refreshes and normal browser sessions.

For example:

localStorage.setItem(
  'vortelle-wishlist',
  JSON.stringify(wishlist)
);

The data can later be retrieved with:

const wishlist = JSON.parse(
  localStorage.getItem('vortelle-wishlist') || '[]'
);

This makes LocalStorage useful for wishlist functionality where the user does not need to log in.

Store Product Identifiers, Not Entire Products

One common mistake is trying to save an entire product object in LocalStorage.

There is usually no reason to do this.

Product data can change, and large objects make synchronization more complicated.

A better approach is to store stable identifiers and let Shopify render the current product information.

For example:

const item = {
  id: productId,
  handle: productHandle
};

The wishlist then acts as a list of references rather than a second product database.

Building the Wishlist Drawer

The drawer can be a normal theme component:

<aside class="wishlist-drawer">
  <div class="wishlist-drawer__header">
    <h2>Wishlist</h2>
    <button type="button" data-wishlist-close>
      Close
    </button>
  </div>

  <div data-wishlist-items></div>
</aside>

JavaScript controls whether the drawer is open and which products are displayed.

For a Shopify theme, this component can live inside the main layout or as a reusable section/snippet depending on the theme architecture.

Shopify themes are designed around reusable layouts, templates, sections, blocks, and snippets, which makes this type of feature relatively straightforward to integrate without introducing an external frontend framework.

Synchronizing Product Cards

Every wishlist button should know which product it represents.

For example:

<button
  type="button"
  data-wishlist-toggle
  data-product-id="{{ product.id }}"
  data-product-handle="{{ product.handle }}"
>
  Add to wishlist
</button>

The JavaScript can then read those attributes and update LocalStorage.

The button should also reflect the current state.

If a product already exists in the wishlist, the UI might change from:

Add to wishlist

to:

Remove from wishlist

This makes the feature feel like a native part of the storefront rather than a separate widget.

Handling Empty States

A good wishlist needs an empty state.

Instead of rendering an empty drawer, show something useful:

Your wishlist is empty.

Save products you want to revisit later.

You can also provide a link back to the collection or product catalog.

Small details like this matter because the wishlist is part of the shopping experience, not just a storage mechanism.

What About Multiple Browser Tabs?

If users can have the store open in multiple tabs, the storage event can help synchronize changes.

window.addEventListener('storage', () => {
  renderWishlist();
});

This event fires when LocalStorage changes in another document from the same origin.

It allows the drawer and product pages to remain reasonably synchronized without constantly polling the browser.

LocalStorage Has Important Limitations

This architecture is intentionally simple.

The wishlist is tied to the browser.

If a customer switches from a laptop to a phone, the wishlist does not automatically follow them.

Clearing browser storage also removes the data.

The wishlist is not automatically associated with a Shopify customer account.

That means LocalStorage is appropriate when the requirement is:

"Let visitors save products for later."

It is less appropriate when the requirement is:

"Customers must have a permanent wishlist available across every device."

The second requirement normally calls for server-side persistence.

When a Shopify App Makes More Sense

A third-party wishlist application can be useful when the store requires:

  • customer account synchronization;
  • cross-device persistence;
  • email reminders;
  • wishlist analytics;
  • sharing;
  • advanced merchandising;
  • admin reporting.

Custom development is often preferable when the requirement is simply a fast, lightweight wishlist drawer with complete control over the UI.

Final Thoughts

A wishlist does not automatically require another Shopify app.

For a browser-based wishlist, LocalStorage can provide a clean architecture with very little overhead.

The important part is defining the requirement first.

If the feature only needs to remember products in the current browser, a custom theme implementation can be enough.

If the wishlist needs accounts, synchronization, analytics, and long-term persistence, a more sophisticated architecture is appropriate.

The best Shopify implementation is not necessarily the one with the most functionality. It is the one that matches the actual requirement without adding unnecessary complexity.

Back to blog