Minicart doesn´t refresh vtexio

Hi,

I´m trying to create an add to cart button that is native to vtex io.
When using all the information from different docs I have found: Get current or create a new cart and Checkout API I´ve came to the point that, I can add a product to the cart however the mini cart doesn´t refresh.

I have to manually refresh the page in order for the mini cart to display the added products.

Does anyone know how to fix this so mini cart is automatically refreshed?

Sidenote: has to be a API or Javascript implementation

thanks in advance.

The only way I found is to use the addItems function from the vtex.order-items app. You can see that this is the same function used in the Add to Cart Button source code.

https://github.com/vtex-apps/add-to-cart-button/blob/master/react/AddToCartButton.tsx

You just need to call this function inside your custom app.
Something like this should work:

await addItems(
      [
            {
                  id: skuId,
                  quantity: quantity,
                  seller: seller
            }
      ]
)