Skip to main content

Backend SDK

Squid provides a backend SDK that enables you to enhance the functionality and security of their application. With the SDK, developers can define and execute the desired backend code written in Typescript.

The code has the ability to access any resources and can be designed to be as complex as necessary. The following tasks can be performed with the backend code:

  • Secure access to various resources
  • Respond to changes in the database
  • Define schedulers
  • Expose webhooks
  • Expose backend functions to the Squid Client
  • And more!

The Squid Backend code has access to the Squid Backend SDK, which is used to customize the backend logic. Most of this customization is done by creating classes that extend the SquidService class. This class provides useful context information, such as authentication details for the user who initiated an action, as well as access to this.squid, a reference to the Squid Client.

By using this.squid, the backend code can perform any task that the client can perform, such as executing queries and mutating data. In addition, it has access to secrets and resources that are forbidden to the client, giving it a wider range of capabilities.

In short, the Squid Backend code has extensive power and flexibility, making it a powerful tool for developers who need to build complex backend functionality for their applications.

Note

It's important to note that code running in the backend project has unrestricted access to your data sources, secrets, and other resources. For instance, any use of this.squid in your backend project will not require authorization and will bypass the security rules. Essentially, think of this as an admin SDK for your backend project.

Getting started

To get started with Squid, you need to generate a backend template project.

You can find the steps in the Squid Console on the application overview page. Just click the Initialize Backend button to begin.

Running the command will create a directory with your backend project, ready to be run locally.

Open the project in your preferred IDE. The code generated includes code for local development and the actual backend functionality, found in the /src/service/ directory. An ExampleService is included with code examples.

Your backend functionality should be built within a class or multiple classes that extend the SquidService class. This class provides context information like the user's authentication details who initiated the action and a reference to the Squid Client. The index.ts file connects the backend code to the Squid server.

Finish setting up your backend by following the next two steps in the console: Create a .env file and Deploy your backend. Instead of deploying your backend, you can also start your backend project locally using the Squid CLI.

Note

If you have an existing backend project that you want to set up on your machine, you can start by cloning the project to your local environment. Next, you'll need to create a .env file, which will store essential information such as your application ID, Squid developer ID, and a few other necessary variables.

To create this file, follow the step-by-step guide found on the application overview page. Start the process by clicking the Create .env file button.

Next steps

After setting up your backend, explore all that the Squid Backend SDK has to offer, or get started with the Client SDK to begin full stack development with Squid.

Explore