Lanka Developers Community

    Lanka Developers

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Shop

    How to fix $supabase does not exist on type in NUXTJS

    Front-End Development
    nuxtjs vue vuejs typescript
    2
    3
    337
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • root
      root Linux Help last edited by root

      I'm getting this error when i access my $supabase nuxt plugin in pages/index.vue

      a4fae784-06fc-4828-8262-c642e21aec0f-image.png

      ~/plugins/supabase.js

          import {createClient} from '@supabase/supabase-js'
      
          export default ({ app },inject) => {
              
              const supabaseUrl = app.$config.supabaseUrl
              const supabaseKey = app.$config.supabaseApi
      
              const supabase = createClient(supabaseUrl, supabaseKey)
      
              inject('supabase', supabase)
          }
      

      i loaded plugin in nuxt config

      plugins: [
          {src: '~/plugins/supabase.js', mode : 'client'}
        ],
      

      Anyone can help to fix this issue, i use typescript with nuxtjs

      1 Reply Last reply Reply Quote 0
      • Nubelle
        Nubelle Web Development last edited by Nubelle

        You have to define a type.

        example :

        data(){
              return {
                $supabase :(this as any).$supabase,
              }
            },
        
        root 1 Reply Last reply Reply Quote 1
        • root
          root Linux Help @Nubelle last edited by

          @nubelle Thanks man it works

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post

          1
          Online

          3.7k
          Users

          1.3k
          Topics

          5.3k
          Posts

          • Privacy
          • Terms & Conditions
          • Donate

          © Copyrights and All right reserved Lanka Developers Community

          Powered by Axis Technologies (PVT) Ltd

          Made with in Sri Lanka

          | |