,

Supabase + React: Backende Artık İhtiyaç Yok!

Posted by


Supabase is an open source Firebase alternative that provides a powerful suite of tools for building web and mobile applications. With Supabase, you can quickly and easily set up a backend for your applications without having to worry about writing any backend code.

In this tutorial, we will walk you through how to set up a simple React application with Supabase as the backend. We will cover how to create a database, set up authentication, and perform basic CRUD operations using Supabase and React.

Step 1: Set up a Supabase account

To get started with Supabase, you will need to create an account on their website. Head over to https://supabase.io/ and sign up for a free account. Once you have created an account, you will be able to access the Supabase dashboard where you can create a new project.

Step 2: Create a new project in Supabase

In the Supabase dashboard, click on the "Create a new project" button to create a new project. Give your project a name and click on the "Create project" button. Once your project is created, you will be provided with a URL and an API key that you will need to connect your React application to Supabase.

Step 3: Set up a database in Supabase

In your Supabase dashboard, click on the "Database" tab and then click on the "Create a new table" button to create a new table in your database. You can define the columns for your table and set up any constraints that you need. Once you have set up your table, you can start adding data to it.

Step 4: Set up authentication in Supabase

In the Supabase dashboard, click on the "Authentication" tab and then click on the "Get started" button to set up authentication for your project. You can choose from several authentication providers, such as email/password, Google, and GitHub. Once you have set up authentication, you will be able to authenticate users in your React application using Supabase.

Step 5: Connect your React application to Supabase

To connect your React application to Supabase, you will need to install the Supabase client library. You can do this by running the following command in your React application:

npm install @supabase/supabase-js

You will also need to import the Supabase client library in your React application and initialize it with your Supabase URL and API key:

import { createClient } from '@supabase/supabase-js';

const supabase = createClient('your-supabase-url', 'your-supabase-api-key');

Step 6: Perform CRUD operations with Supabase and React

Now that you have connected your React application to Supabase, you can start performing CRUD operations with your database. You can use the Supabase client library to fetch data from your database, insert new data, update existing data, and delete data.

Here is an example of how you can fetch data from your database and display it in your React application:

import React, { useState, useEffect } from 'react';

const App = () => {
  const [data, setData] = useState([]);

  useEffect(() => {
    const fetchData = async () => {
      const { data, error } = await supabase.from('your-table-name').select('*');
      if (error) {
        console.error(error);
      } else {
        setData(data);
      }
    };

    fetchData();
  }, []);

  return (
    <div>
      {data.map((item) => (
        <div key={item.id}>{item.name}</div>
      ))}
    </div>
  );
};

export default App;

This is just a basic example of how you can fetch data from your Supabase database and display it in your React application. You can also use the Supabase client library to insert, update, and delete data in your database.

Conclusion

In this tutorial, we have walked you through how to set up a simple React application with Supabase as the backend. We covered how to create a database, set up authentication, and perform basic CRUD operations using Supabase and React. With Supabase, you can quickly and easily set up a backend for your applications without having to write any backend code. Happy coding!

0 0 votes
Article Rating
13 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@erkant
2 months ago

Ücretlendirmewi yüksek değilse karışık olmayan mobil uygulamalar için kullanışlı gibi duruyor. Anlatım da çok iyidi bu arada teşekkürler.

@hasirciogli
2 months ago

Harika kanka yeni yeni gelişiyor türk yazılımcılar. Next.js öğren tavsiye ederim. next.js öğrenirsen herşey değişecek 🙂

@nurettinyildiz2566
2 months ago

Yani hobi projeler için olabilir ama real time projectler için Backend her türlü şart.

@muhammetakduman9135
2 months ago

anlatım da 10 numara, sağol bro

@emirwildrift
2 months ago

icerik fikri cok guzel. lakin basligi, yazmak icin yazmissin :D. Hic verimli degil.

@rznkolds
2 months ago

Şahsen ben bunun yerine next js kullanırım firebase konusuna gelirsekte bence next js içerisinde kullanırken dahi bir karmaşıklığı yok şuan bir proje yapıyorum next-js + firebase kullanıyorum

@yunus4569
2 months ago

Ben reactte yeniyim ve ilk web uygulamamı firebase ile yaptım, sizce daha sonraki projeler için bu teknolojiyi öğrenmeli miyim?

Anonymous
2 months ago

Bu işin güvenlik tarafı nasıl oluyor? Sonuçda reactjs front'da çalışır.

@Alp-Eren-Guney
2 months ago

Laravelden react’a geçmek o kadar zorluyor ki….

@Gokhan-er8qv
2 months ago

bu tür veri tabanlarını sevmiyorum çünkü anlamadığm ve anlamakla uğraşmak istemediğim bir veri erişim kodlama türüne sahipler (örneğin hangi user hangi user'ın todo'sunu görebilir ya da silebilir gibi bu tür şeylerin hepsini tek tek yazıp belirlemen gerekiyor aynı firebase gibi) kısacası bununla uğraşacağıma açarım bi backend 10 dakika sürer sürmez..

@lreaxx
2 months ago

nabacan reacti 50 yıllık php varken

@BaranAdal-le8pi
2 months ago

İçerik harika, ellerine sağlık. Next & Supabase ile bir seri yaparsan süper olur. Bu konuda yerli içerik pek fazla yok.

@PeriklesPeriklesoglu
2 months ago

dostum selamlar öncelikle içerik için teşekkürler. aklıma takılan bir durum var supabase'i next.js ile kullanmak ile react ile kullanmak arasında ne gibi bir fark var?