You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Complete SDK and APIs integrations with Supabase
10
-
11
-
This monorepo houses the collection of Elixir SDK packages for integrating with Supabase, the open-source Firebase alternative. Our goal is to offer developers a seamless integration experience with Supabase services using Elixir.
12
-
13
-
## Packages Overview
14
-
15
-
-**Supabase Potion**: Main entrypoint for the Supabase SDK library, providing easy management for Supabase clients and connections. [Guide](./apps/supabase_potion/README.md).
16
-
-**Supabase Storage**: Offers developers a way to store large objects like images, videos, and other files. [Guide](./guides/storage.md)
17
-
-**Supabase PostgREST**: Directly turns your PostgreSQL database into a RESTful API using PostgREST. [Guide](#)
18
-
-**Supabase Realtime**: Provides a realtime websocket API, enabling listening to database changes. [Guide](#)
19
-
-**Supabase Auth**: A comprehensive user authentication system, complete with email sign-in, password recovery, session management, and more. [Guide](./apps/supabase_auth/README.md)
20
-
-**Supabase UI**: UI components to help build Supabase-powered applications quickly. [Guide](#)
21
-
-**Supabase Fetcher**: Customized HTTP client for making requests to Supabase APIs. [Guide](./guides/fetcher.md)
3
+
Where the magic starts!
22
4
23
5
## Getting Started
24
6
@@ -34,89 +16,81 @@ def deps do
34
16
end
35
17
```
36
18
37
-
Then you can each package for the service you want to use. For example, if you want to use only the `Storage` integration:
For more information, refer to the [supabase_potion](./apps/supabase_potion/README.md) readme!
56
-
57
-
## Supabase Services
58
-
59
-
The Supabase Elixir SDK allows you to interact with various Supabase services:
60
-
61
-
### Supabase Storage
62
-
63
-
Supabase Storage is a service for storing large objects like images, videos, and other files. It provides a simple API with strong consistency, similar to AWS S3.
64
-
65
-
### Supabase PostgREST
66
-
67
-
PostgREST is a web server that turns your PostgreSQL database into a RESTful API. It automatically generates API endpoints and operations based on your database's structure and permissions.
68
-
69
-
### Supabase Realtime
19
+
### Clients
70
20
71
-
Supabase Realtime offers a realtime WebSocket API powered by PostgreSQL notifications. You can use it to listen to changes in your database and receive updates instantly as they happen.
21
+
A `Supabase.Client` is an Agent that holds general information about Supabase, that can be used to intereact with any of the children integrations, for example: `Supabase.Storage` or `Supabase.UI`.
72
22
73
-
### Supabase Auth
23
+
`Supabase.Client` is defined as:
74
24
75
-
Supabase Auth is a comprehensive user authentication system that includes features like email and password sign-in, email verification, password recovery, session management, and more, out of the box.
25
+
-`:name` - the name of the client, started by `start_link/1`
26
+
-`:conn` - connection information, the only required option as it is vital to the `Supabase.Client`.
27
+
-`:base_url` - The base url of the Supabase API, it is usually in the form `https://<app-name>.supabase.io`.
28
+
-`:api_key` - The API key used to authenticate requests to the Supabase API.
29
+
-`:access_token` - Token with specific permissions to access the Supabase API, it is usually the same as the API key.
30
+
-`:db` - default database options
31
+
-`:schema` - default schema to use, defaults to `"public"`
32
+
-`:global` - global options config
33
+
-`:headers` - additional headers to use on each request
34
+
-`:auth` - authentication options
35
+
-`:auto_refresh_token` - automatically refresh the token when it expires, defaults to `true`
36
+
-`:debug` - enable debug mode, defaults to `false`
37
+
-`:detect_session_in_url` - detect session in URL, defaults to `true`
38
+
-`:flow_type` - authentication flow type, defaults to `"web"`
39
+
-`:persist_session` - persist session, defaults to `true`
40
+
-`:storage` - storage type
41
+
-`:storage_key` - storage key
76
42
77
-
### Supabase UI
43
+
##Usage
78
44
79
-
Supabase UI provides a set of UI components to help you build Supabase-powered applications quickly. It's built on top of Tailwind CSS and Headless UI, and it's fully customizable. The package even includes `Phoenix.LiveView` components!
45
+
The Supabase Elixir SDK provides a flexible way to manage `Supabase.Client` instances, which can, in turn, manage multiple `Supabase.Client` instances. Here's a brief overview of the key concepts:
80
46
81
-
### Supabase Fetcher
47
+
### Starting a Client
82
48
83
-
Supabase Fetcher is a customized HTTP client for Supabase, mainly used in Supabase Potion. It gives you complete control over how you make requests to any Supabase API.
84
-
85
-
## General Roadmap
86
-
87
-
If you want to track integration-specific roadmaps, check their own README.
88
-
89
-
-[x] Fetcher to interact with the Supabase API in a low-level way
90
-
-[x] Supabase Storage integration
91
-
-[ ] Supabase UI for Phoenix Live View
92
-
-[ ] Supabase Postgrest integration
93
-
-[x] Supabase Auth integration
94
-
-[ ] Supabase Realtime API integration
49
+
You can start a client using the `Supabase.Client.start_link/1` function. However, it's recommended to use `Supabase.init_client!/1`, which allows you to pass client options and automatically manage `Supabase.Client` processes.
Well, I tried to to use the [supabase-elixir](https://github.com/treebee/supabase-elixir) package but I had some strange behaviour and it didn't match some requirements of my project. So I started to search about Elixir-Supabase integrations and found some old, non-maintained packages that doesn't match some Elixir "idioms" and don't leverage the BEAM for a more integrated experience.
58
+
Ensure your Supabase configurations are set:
100
59
101
-
Also I would like to contribute to OSS in some way and gain more experience with the BEAM and HTTP integrations too. So feel free to not to use, give some counter arguments and also contribute to these packages!
-`supabase_base_url`: The base URL of your Supabase project! More information on how to find it can be seen on the [next section](#how-to-find-my-supabase-base-url?)
70
+
-`supabase_api_key`: The secret of your Supabase project! More information on how to find it can be seen on the [next section](#how-to-find-my-supabase-api-key?)
71
+
-`manage_clients`: Enable or disable the internal client management by the library. Defauls to `true`, see more on the [library supervisor documentation](https://hexdocs.pm/supabase_potion/Supabase.ClientSupervisor.html).
107
72
108
-
## Contributing
73
+
Make sure to set the environment variables `SUPABASE_BASE_URL` and `SUPABASE_API_KEY`.
109
74
110
-
Contributions, issues, and feature requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
75
+
### How to find my Supabase base URL?
111
76
112
-
## Acknowledgements
77
+
You can find your Supabase base URL in the Settings page of your project.
78
+
Firstly select your project from the initial Dashboard.
79
+
On the left sidebar, click on the Settings icon, then select API.
80
+
The base URL is the first field on the page.
113
81
114
-
This SDK is a comprehensive representation of Supabase's client integrations. Thanks to the Supabase community for their support and collaboration.
82
+
### How to find my Supabase API Key?
115
83
116
-
## License
84
+
You can find your Supabase API key in the Settings page of your project.
85
+
Firstly select your project from the initial Dashboard.
86
+
On the left sidebar, click on the Settings icon, then select API.
87
+
The API key is the second field on the page.
117
88
118
-
[MIT](LICENSE)
89
+
There two types of API keys, the public and the private. The last one
90
+
bypass any Row Level Security (RLS) rules you have set up.
91
+
So you shouldn't use it in your frontend application.
119
92
120
-
---
93
+
If you don't know what RLS is, you can read more about it here:
With the Supabase Elixir SDK, you have the tools you need to supercharge your Elixir applications by seamlessly integrating them with Supabase's powerful cloud services. Happy coding! 😄
96
+
For most cases you should prefer to use the public "anon" Key.
0 commit comments