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.
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
:
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
🗂️ Collection reference
In Squid, a collection reference is a reference to a collection in a database. You can use it to read or write data to the collection. A collection can refer to a table in a relational database or a collection in a NoSQL database.
📑 Document reference
In Squid, a document reference is a reference to a specific record in a collection. You can use it to read or write data to the document.
🪪 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.
🔍 Queries
Squid offers a robust query system that allows you to access your data from various sources, including joining data across multiple databases with real-time query support.
🧬 Mutations
Mutations in Squid are powerful tools that can be applied on an instance of a DocumentReference and used for modifying the data of a document. They can be applied locally and reflect immediately, providing a fast and responsive user experience.
🔁 Transactions
In Squid, transactions are a powerful tool for performing multiple mutations on one or more documents in an atomic manner.
Native queries
Native queries allow you to execute raw SQL or other database-specific queries directly against the database. This can be useful when you need to perform operations that are not easily accomplished with the Squid Client SDK alone.
Calling your API integration
By integrating your APIs with Squid, you can take advantage of highly configurable security in the backend and intuitive functionality with the Squid Client SDK
Distributed lock management
Manage access to your shared resources in real-time to transact data in the desired order
🤫 Secrets
With secrets, Squid provides state of the art support for managing sensitive data like API keys, passwords, certificates and more. While most secret management can be done in the Squid Cloud Console, the Squid Client SDK also provides a secrets API that allows for programmatic management.
Storage
Learn how to securely manage uploads and downloads of files with Squid Storage.
Squid AI
Squid AI works with your data to provide domain-specific insights that you and your users need.