diff --git a/README.md b/README.md index 982da82..9fea51c 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,10 @@ This module will inject $supabase in the context of your application. Using $supabase you can access to the SupabaseClient object of the [Supabase Client for JavaScript](https://supabase.io/docs/reference/javascript/supabase-client). +### Shortcuts + +This module also inject $supaAuth & $supaStorage that are nothing more than a shorcut for $supabase.auth and $supabase.storage. + ## Examples ### Fetching data diff --git a/lib/plugin.js b/lib/plugin.js index 1bc4ca2..832de13 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -1,6 +1,12 @@ import { createClient } from '@supabase/supabase-js' -export default function(_, inject) { +export default function (_, inject) { const client = createClient('<%= options.url %>', '<%= options.key %>') inject('supabase', client) + + const auth = client.auth + inject('supaAuth', auth) + + const storage = client.storage + inject('supaStorage') } diff --git a/types/index.d.ts b/types/index.d.ts index 83789d5..57d5f7b 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,25 +1,35 @@ import { SupabaseClient } from '@supabase/supabase-js' +import { SupabaseAuthClient } from '@supabase/supabase-js/dist/main/lib/SupabaseAuthClient' +import { SupabaseStorageClient } from '@supabase/supabase-js/dist/main/lib/SupabaseStorageClient' declare module '@nuxt/vue-app' { interface Context { $supabase: SupabaseClient + $supaAuth: SupabaseAuthClient + $supaStorage: SupabaseStorageClient } } declare module '@nuxt/types' { interface Context { $supabase: SupabaseClient + $supaAuth: SupabaseAuthClient + $supaStorage: SupabaseStorageClient } } declare module 'vue/types/vue' { interface Vue { $supabase: SupabaseClient + $supaAuth: SupabaseAuthClient + $supaStorage: SupabaseStorageClient } } declare module 'vuex/types/index' { interface Store { $supabase: SupabaseClient + $supaAuth: SupabaseAuthClient + $supaStorage: SupabaseStorageClient } }