Adding Oracle Backend with Supabase APIs to Your Apps

Register a web app in the Console, copy its configuration, and connect it using the relational JavaScript SDK.

Before You Begin

Before you add Oracle Backend with Supabase APIs to an app, make sure that:

See Also:

For background and environment setup instructions, see:

Introduction

Oracle Backend with Supabase APIs services are shared by the project, not by individual apps. When you register an app in a project, the Console generates app-specific configuration that identifies the:

The SDK uses this configuration to send your app’s requests to the selected backend in Oracle Backend with Supabase APIs.

If you later change the project’s enabled services, request the app configuration again from the Console so the app reflects the updated project state.

Add Oracle Backend with Supabase APIs to a Web App

This section shows how to register a web app, install the JavaScript SDK, paste in the generated configuration, and initialize Oracle Backend with Supabase APIs.

Prerequisites

Before you begin, ensure that:

For new web apps, Oracle recommends the modular JavaScript SDK.

Register Your Web App

  1. Open the Oracle Backend with Supabase APIs Console. Open a relational project, or create one by following Creating a Project.

    Configure the authentication or object storage services your app needs before copying its SDK configuration. If you add or change services later, copy the updated configuration again.

  2. On the project’s Overview page, select Web.

    Figure 4-1 Register a Web App from the Console

    Description of the illustration dds-app-register-web.png

  3. For App Nickname, enter a name such as TodoApp, then select Register App.

    Figure 4-2 Name the Web App

    Description of the illustration dds-app-register-name.png

  4. At Install SDK, review the installation command, then select Next. Install the package as described in Install the JavaScript SDK.

  5. At Configure SDK, select Copy config and save the generated configuration for your application. Select Done to close the registration dialog.

For web apps, Oracle Backend with Supabase APIs uses a JavaScript configuration object that you paste into your application code.

To copy the configuration again, open Project settings > Applications, select your web app, and select Copy config in SDK config.

Figure 4-3 Retrieve the Web App Configuration

Description of the illustration dds-app-copy-config.png

Install the JavaScript SDK

Install the relational JavaScript SDK package from npm:

npm install @fusabase/fusabase-relational

Initialize the JavaScript SDK

Import createClient and create a client with the ORDS host and your app configuration:

import { createClient } from "@fusabase/fusabase-relational";

const client = createClient("http://localhost:8080/ords/fusabase_user/", {
  schema: "fusabase_user",
  app_name: "TodoApp",
  app_type: "WEB",
  app_id: "APP_ID",
  project_id: "PROJECT_ID",
  objs_type: "base",
  storage_bucket: "STORAGE_BUCKET",
  auth_type: "base",
  auth_id: "AUTH_ID",
  backend_type: "RELATIONAL"
});

Replace the following values with those copied from the Console:

Replace the example host, schema, app name, and service settings if your generated configuration differs. Keep the trailing / in the ORDS host URL and retain the configuration’s backend_type: "RELATIONAL" value.

The required configuration keys are schema, app_type, app_id, project_id, objs_type, storage_bucket, auth_type, and auth_id. The SDK accepts app_name as an optional value; keep it when copying the generated configuration.

Verify Application Data Access

Initializing a client does not verify connectivity or DDS permissions. Follow Verify Application Data Access to create a table, add rows, and configure a data grant through the Console. Then use your initialized client to confirm that the application receives only the permitted row.

Troubleshooting

By default, database HTTP responses produce an envelope containing data, error, count, status, and statusText. Check error before using returned data. Input validation, transport, or response-parsing failures can throw, so also handle exceptions:

To use the following insert example, first create a todos table and a data grant that permits the insert.

try {
  const { data, error, status } = await client
    .from("todos")
    .insert({ title: "Write documentation" });

  if (error) {
    console.error("Message:", error.message);
    console.error("HTTP status:", error.status);
    console.error("Code:", error.code);
    console.error("Details:", error.details);
    console.error("Hint:", error.hint);
  } else {
    console.log(data);
  }
} catch (error) {
  console.error("Request failed:", error);
}

Use throwOnError() when you want HTTP error responses to throw a RelationalDatabaseError. The error can provide message, status, code, details, and hint values.

Next Steps

After verifying application data access, continue with the service-specific tasks for your project:

See Also:

For project concepts and project lifecycle tasks, see: