Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fireproof/cloud

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fireproof/cloud

Fireproof Cloud gateway for Fireproof

  • 0.19.112
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Fireproof Cloud

This gateway intended for use with Fireproof Cloud.

Usage

You can call the connect function with a database and it will provision a remote UUID for the database, and sync the database to the remote. It will also log a URL to the console that you can open in a browser to connect to the database, as well as try to open the URL in a new tab. Tell us what you think about this workflow!

import { fireproof } from "@fireproof/core";
import { connect } from "@fireproof/cloud";

const database = await fireproof("my-db-name");
const connection = await connect(database);

With React Hooks

In a React component, you can use the useFireproof hook to get the database and then call connect (it is safe to call connect multiple times, but in this example we're using a state variable to store the dashboard URL).

import { useFireproof } from "use-fireproof";
import { connect } from "@fireproof/cloud";

const { database } = useFireproof("my-db-name");
const [dashboardUrl, setDashboardUrl] = useState<string | undefined>();

// there is a useConnection hook coming soon
useEffect(() => {
  connect(database).then((connection) => {
    setDashboardUrl(connection.dashboardUrl?.toString());
  });
}, [database]);

The Second Argument

The second argument to connect is the remote database name. This will be assigned for you if you don't provide one, and the created name will be persisted locally.

The most common way to use this is if you want to sync to a remote database. The UUID will have been assigned when on first sync, and now you want to connect a new client to that remote.

const connection = await connect(database, "my-remote-uuid");

If you provide a name, it will be used as the remote database name. If you want to control the name, you should use a prefix unique to your app, so no one else uses your endpoint. This is useful if you want the database name to come from your URL slug, like /my-app/my-db-name.

const connection = await connect(database, `com.my-app.v1.${database.name}`);

Note: if your database already has data in it, connecting to a new remote will do nothing. To prevent data lost, you need to rename the local database to an unused name and the connect.

No Warranty, For Evaluation Purposes

This preview of Fireproof Cloud doesn't even have login, so don't expect your data to be persisted, etc. Please give us feedback on the workflow! We'll be adding login and access control soon.

The source of truth on this stuff is the team. Join us on Discord if you want to chat!

Keywords

FAQs

Package last updated on 19 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc