Free serverless for restAPI with supabase

Nasri Adzlani
3 min readJul 28, 2024

--

Supabase is an open-source Firebase alternative that is rapidly gaining popularity in the developer community. supabase has many features like Postgres database, Authentication, instant APIs, Edge Functions, Realtime subscriptions, Storage, and Vector embeddings.

Supabase Logo. src https://www.squarepeg.vc/companies/supabase

This article is a summary of my experience learning about Supabase for my research. First, I created a Supabase account at Supabase Dashboard. You can sign up using your email and password, GitHub account, or other SSO options. After completing the registration details, you can create a project in the Supabase dashboard.

Once you’ve created your project, go to Supabase Dashboard. The first thing you’ll need to do is install the Supabase CLI on your local machine. For reference, I’m using a Mac.

brew install supabase/tap/supabase

For more details, you can check Supabase CLI Getting Started Guide. After installing the CLI, you can log in to Supabase directly from your terminal.

supabase login

Supabase will redirect you to your browser to log in and sync your account from the browser to your local machine. After that, you can create a function project like this:

supabase functions new <function-name>

When you open the project, it will look like this:

After some searching, I found that I needed to install the Deno extension in VSCode.

Deployment:

Deploying this serverless function is quite simple. Just run the following command:

supabase functions deploy pilkada-mobile-svc --project-ref <id>

When the deployment is successful, your terminal will show something like this:


Bundling Function: pilkada-mobile-svc
Download https://jsr.io/@supabase/functions-js/meta.json
Download https://jsr.io/@supabase/functions-js/2.4.2_meta.json
Deploying Function: pilkada-mobile-svc (script size: 2.261MB)
Deployed Functions on project <id>: pilkada-mobile-svc
You can inspect your deployment in the Dashboard: https://supabase.com/dashboard/project/<id>/functions

Testing:

I’m using HTTPie to test my service. It looks like this:

Conclusion

Learning Supabase has been an insightful journey. From setting up an account and creating projects to deploying serverless functions, the process is straightforward and user-friendly. The documentation and tools provided by Supabase, like the CLI and integration with Deno in VSCode, make it easy to get started and deploy your services efficiently.

For testing, HTTPie proved to be a valuable tool, allowing me to quickly and easily verify my endpoints. Whether you’re a beginner or an experienced developer, Supabase offers a robust platform for building and deploying applications.

Feel free to share your experiences or any tips you have in the comments. Happy coding!.

--

--

No responses yet