apps/www/_blog/2020-10-30-improved-dx.mdx
UPDATE 16/08/2022: supabase-js v2 is out and focuses on “quality-of-life” improvements for developers. V2 includes Type support, new auth methods, realtime multiplayer sneak peek, and more: Read the blog post
Before digging into the improvements, we're excited to point out our new developer docs. While they're still a work in progress, here are some things we think you'll like:
We attribute this improvement to community feedback. This has significantly improved the developer experience.
Previously we would throw errors:
try {
const { body } = supabase.from('todos').select('*')
} catch (error) {
console.log(error)
}
And now we simply return them:
const { data, error } = supabase.from('todos').select('*')
if (error) console.log(error)\n
// else, carry on ..
After testing this for a while we're very happy with this pattern. Errors are handled next to the offending function. Of course you can always rethrow the error if that's your preference.
gotrue-jsOur goal for supabase-js is to tie together many sub-libraries. Each sub-library is a standalone implementation for a single external system. This is one of the ways we support existing open source tools.
To maintain this philosophy, we created gotrue-js, a library for Netlify's GoTrue auth server. This library includes a number of new additions, including third-party logins.
Previously:
const {
body: { user },
} = await supabase.auth.signup('[email protected]', 'password')
Now:
const { user, error } = await supabase.auth.signUp({
email: '[email protected]',
password: 'password',
})
supabase-js, postgrest-js, gotrue-js, and realtime-js.supabase-js have been solved.select() instead of select(*)We've bumped the major version because there are a number of breaking changes. We've detailed these in the release notes, but here are a few to be aware of:
signup() is now signUp() and email / password is passed as an objectlogout() is now signOut()login() is now signIn()ova() and ovr() are now just ov()body is now dataPreviously:
const { body } = supabase.from('todos').select('*')
Now:
const { data } = supabase.from('todos').select()
We have documented all of the changes in the release notes.
To summarise the steps:
npm install @supabase/supabase-js@latestbody constants to datasupabase.auth functions with the new Auth interface