nuxt-shopify icon indicating copy to clipboard operation
nuxt-shopify copied to clipboard

Any plans for Nuxt 3 support?

Open Baroshem opened this issue 3 years ago • 5 comments
trafficstars

Are you planning to update this module to be Nuxt 3 compatible (to use composables like useShopify, etc)?

Baroshem avatar Jan 07 '22 14:01 Baroshem

Hey @Baroshem, that's the plan! Just need to free up some time to focus on it ✌🏻

Gomah avatar Jan 07 '22 17:01 Gomah

Nuxt 3 RC2 is out with RC3 on the way. Are there any progress updates worth mentioning or perhaps an ETA?

mweber06 avatar May 07 '22 09:05 mweber06

Hi @Gomah!

Thanks for your work! Any news about updating the plugin for Nuxt3 compatibility?

Thanks! Brice

keroth- avatar May 25 '22 06:05 keroth-

Hi Everybody,

with the help of the composition API, the shopify-buy can be integrated directly. This trick simplifies the code and no additional dependencies are needed.

const shopify = Client.buildClient({
  domain: process.env.shopifyDomain,
  storefrontAccessToken: process.env.shopifyAccessToken,
  language: 'de-DE',
})

For migration for $shopify to a composable file, the $shopify can be wrapped with wrapProperty function.

const wrapProperty =
  (property, makeComputed = true) =>
  () => {
    const vm = getCurrentInstance().proxy
    return makeComputed ? computed(() => vm[property]) : vm[property]
  }

const useShopify = wrapProperty('$shopify', false)

I performed the migration from nuxt-shopify to shopify-buy in this example.

https://github.com/naschidaniel/fly-tirol/commit/379eb797faa117cf69a8076b2da93884325fb5ee

The composable is thus nuxt3 ready

All the best,

Daniel

@Gomah, Thank you for your work. The module worked perfect before the composition API was created.

naschidaniel avatar Jun 22 '22 19:06 naschidaniel

Can anyone link me to a slim example using shopify-buy with Nuxt 3?

james0r avatar Jan 30 '23 04:01 james0r