Gomah / nuxt-shopify

🛍 Seamless Shopify Buy SDK integration with Nuxt.js.
https://nuxt-shopify-docs.vercel.app
MIT License
352 stars 29 forks source link

Any plans for Nuxt 3 support? #694

Open Baroshem opened 2 years ago

Baroshem commented 2 years ago

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

Gomah commented 2 years ago

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

mweber06 commented 2 years ago

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

keroth- commented 2 years ago

Hi @Gomah!

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

Thanks! Brice

naschidaniel commented 2 years ago

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.

james0r commented 1 year ago

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