supabase icon indicating copy to clipboard operation
supabase copied to clipboard

How to use useAsyncData and Supabase in composable while preserving type prediction?

Open Zebnastien opened this issue 2 years ago • 0 comments

Hello everyone,

Using Supabase and Nuxt is smooth as butter thanks to this module. Thanks to all the teams for the wonderful work! 👍🏼

I am trying to implement a composable to manage my calls. So I started with the example from the NuxtSupabase documentation:

image

This works fine, and I can see the return type. Now I want to centralize some logic in a composable. Here is my solution:

image

And the associated composable useDatabase:

image

This all works fine, but I lose the Supabase client return type prediction. No matter how much I try different ways of doing things, I systematically lose type inference.

How to manage the Supabase client with useAsyncData in separate composable while benefiting from type prediction? Am I missing something?

Zebnastien avatar Sep 15 '23 22:09 Zebnastien