Is there a way to trigger a mini cart refresh with a custom component

I’m currently working on a custom add to cart button, but when updating the cart, the mini cart doesn’t refresh. Is there a hook or something that can be used to refresh the mini cart?

@georgebrindeiro @tyler

Hey Paulo,
Are you ok?

Did you see that doc GitHub Minicart VTEX

You also can use the function vtexjs.checkout.getOrderForm()

CS Pleno
Support Analyst

1 Like

Hello @Paulo.ribeiro ,

I think that is the Out of the Box feature of VTEX, whenever you add any of the product in the cart, it automatically refresh the Minicart and update it.

I don`t think you would required any such custom development

1 Like

Hi @Paulo.ribeiro there is an addToCart.gql mutation in Vtex which can help you in updating the MiniCart.
Product Customizer Add To Cart
You can take a look over here and see if this helps. :slight_smile:

You could use the addItems from the useOrderItems() hook.
It expects to receive an array of objects.


import { useOrderItems } from 'vtex.order-items/OrderItems'

const Example = () => {
    const { addItems } = useOrderItems()

    const myItem = [{
        'id': sku,
        'name': name,
        'quantity': 1,
        'seller': seller