Today we're releasing supabase-js version 1.0, and it comes with some major Developer Experience improvements.
New Docs
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:
- The Reference Docs are auto-generated from our TypeScript definitions and then enriched with examples. This forces us to document our code and makes it easier to keep everything in sync.
- We added placeholders for the other languages that the community is developing. They have already started with Python, C#, Dart, Rust, and Swift. Expect to see the docs filling up soon!
- We've added sections for all of the open source tools we use, including Postgres, PostgREST, GoTrue, and Realtime. We'll be filling these with lots of valuable information including self-hosting, benchmarks, and simple guides.
Errors are returned, not thrown
We attribute this improvement to community feedback. This has significantly improved the developer experience.
Previously we would throw errors:
1try { 2 const { body } = supabase.from('todos').select('*') 3} catch (error) { 4 console.log(error) 5} 6
And now we simply return them:
1const { data, error } = supabase.from('todos').select('*') 2if (error) console.log(error)\n 3// else, carry on .. 4
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.
We created gotrue-js
Our 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 libary includes a number of new additions, including third-party logins.
Previously:
1const {
2 body: { user },
3} = await supabase.auth.signup('someone@email.com', 'password')
4
Now:
1const { user, error } = await supabase.auth.signUp({
2 email: 'someone@email.com',
3 password: 'password',
4})
5
Enhancements and fixes
- Native TypeScript. All of our libraries are now natively built with TypeScript:
supabase-js
,postgrest-js
,gotrue-js
, andrealtime-js
. - Better realtime scalability: we only generate one socket connection per Supabase client. Previously we would create a connection for every subscription.
- We've added support for OAuth providers.
- 60% of minor bugs outstanding for
supabase-js
have been solved. - You can use
select()
instead ofselect(*)
Breaking changes
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 nowsignUp()
andemail
/password
is passed as an objectlogout()
is nowsignOut()
login()
is nowsignIn()
ova()
andovr()
are now justov()
body
is nowdata
Previously:
1const { body } = supabase.from('todos').select('*') 2
Now:
1const { data } = supabase.from('todos').select() 2
Upgrading
We have documented all of the changes in the release notes.
To summarise the steps:
- Install the new version:
npm install @supabase/supabase-js@latest
- Update all your
body
constants todata
- Update all your
supabase.auth
functions with the new Auth interface
Get started
- Start using Supabase today: app.supabase.io
- Make sure to star us on GitHub
- Follow us on Twitter
- Become a sponsor