Skip to main content

Client SDK

The Squid Client SDK is a Typescript library that enables client applications to connect to the Squid server and securely access the various services provided by Squid. The SDK allows the client to:
  • Fetch data from multiple data sources (including joins).
  • Modify data with transaction support.
  • Utilize Squid's built-in NoSQL database to store and retrieve data.
  • Access GraphQL and OpenAPI endpoints.
  • Execute backend functions.
  • Most of the Client SDK functionality is local first, meaning that if a user updates a record in the database, it will be reflected locally immediately and then synced to the database. This allows Squid to provide real-time updates for your applications.
Note

The Squid Client SDK is available for both frontend and custom backend development. This means you can use the SDK in your frontend application as well as in your backend functions, allowing for better code sharing and a simplified development process.

On the Squid backend, the Squid Client SDK is readily available, and there's no need to initialize it. You can access it directly using this.squid inside your backend functions.

Client SDK setup

Use npm to install the Client SDK:

npm install @squidcloud/client

The Squid client can be used across different frameworks and platforms. To initialize the Squid client, you will need to import the Squid class from the SDK and create an instance of the Squid client by passing your appId and region as configuration options. For local development, you will also need to include your environmentId and squidDeveloperId:

Client code
import { Squid } from '@squidcloud/client';

const squid = new Squid({ appId: 'YOUR_APP_ID', region: 'YOUR_REGION' });

The Squid class serves as the primary entry point for the Squid Client SDK, offering a comprehensive array of functionality for accessing the database, executing backend functions, managing data, and more. Upon instantiating the Squid class, you will have access to all of these capabilities. To learn more about what the Client SDK has to offer, read about querying Squid's database or additional functionality.

Explore

🪪 Document IDs

Document IDs are an essential part of Squid's data model, and they play a crucial role in identifying and accessing specific documents in a collection. In Squid, document IDs are unique identifiers that can be either automatically generated by the server or manually specified by the user. There are different requirements for document IDs based on whether you use Squid's built-in database or other external database integrations. If you use Squid with a non-built-in database, follow the directions in the Non-built-in integrations section.