skip to Main Content

how to connect node js and supabase .I have completed front end using react . I need to get image as input from the user and store it in the DB.I need to fetch those images and display it in cards.

I have no idea as I am new to supabase.

2

Answers


  1. You need to use @supabase/supabase-js package to connect with supabase database.

    npm install @supabase/supabase-js
    

    dbConfig.ts

    import { createClient } from '@supabase/supabase-js'
    export const supabase = createClient('https://<project>.supabase.co', '<your-anon-key>')
    

    For more details refer supabase tutorial.

    Login or Signup to reply.
  2. you will write this in index.js

    const mongoose = require('mongoose');
    
    const databaseName = 'products';
    const username = 'admin';
    const password = '1234';
     
    mongoose.connect(`mongodb+srv:// ${username}:${password} .net/${databaseName}`,
    
    e=() =>{
    if(e){console.log(e);}else{console.log("connected to database");}}
    );
    

    write this part in the terminal
    If used this way, you don’t need to download the MongoDB program to the device.

    $ npm install mongoose
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search