Custom elements should be defined on client-side only. There are a couple of things you can do to ensure this.
You can implement a condition which checks for the environment such as the following one:
if (typeof window !== 'undefined') {
window.__LD_ASSET_PATH__ = '/'
const { defineCustomElements } = await import(
'@emdgroup-liquid/liquid/dist/loader'
)
defineCustomElements()
}
You can also use lifecycle hooks, if available, for running code on the client side only. For instance, in React based applications you can use the effect hook:
useEffect(()=>{
window.__LD_ASSET_PATH__ = '/'
const { defineCustomElements } = await import(
'@emdgroup-liquid/liquid/dist/loader'
)
defineCustomElements()
}, [])
For working examples check out our sandbox apps.