Skip to content

Commit

Permalink
added shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
imlautaro committed Mar 31, 2021
1 parent 55c2c47 commit c2441ea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion lib/plugin.js
Original file line number Diff line number Diff line change
@@ -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')
}
10 changes: 10 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -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<S> {
$supabase: SupabaseClient
$supaAuth: SupabaseAuthClient
$supaStorage: SupabaseStorageClient
}
}

0 comments on commit c2441ea

Please sign in to comment.