Search code examples
vue.jsvuejs2realmvuejs3

How to use Realm SDK with vue3


i have use realm sdk in vue2 with this syntax

// file scr/plugins/realm.js

import Vue from 'vue';
import {App} from 'realm-web';
Vue.prototype.realmApp = new App({id: 'artes-realm-vl12'})

//file scr/main.js
import './plugins/realm';

but in Vue3 this syntax is't working anymore can you please help me how to solve with this problem thank you


Solution

  • In main.js add that app as global property :

    import {createApp} from 'vue'
    import {App} from 'realm-web';
    
    import app from './App.vue'
    
    const myApp=createApp(app)
    
    myApp.config.globalProperties.realmApp = new App({id: 'artes-realm-vl12'})
    
    myApp.mount('#app');