Skip to main content

Customize the backend

Out of the box, Squid hosts a backend (the Squid Server) to connect your client and your data sources. Squid is fully functional without ever needing to customize this backend other than setting up security rules.

However, for most production use cases you'll need a way to secure your data, execute backend functions, define schedulers, encapsulate complex processes, and more.

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.

Add backend functionality

To add this additional functionality, you'll need to create a Squid backend project. To begin you'll need to follow the steps as described here Create a backend project.

Running your backend locally

At this point you can start your backend project locally by running

squid start

This will start a local version of your backend connected to your dev version of your application. After running this you can modify your client application by adding the environmentId: 'dev' option when initializing Squid.

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

const squid = new Squid({
appId: 'YOUR_APP_ID',
region: 'YOUR_APP_REGION', // example: 'us-east-1.aws'
environmentId: 'dev',
});

Once you are done customizing your backend, you can deploy it to Squid by running

squid deploy --apiKey YOUR_API_KEY --environmentId TARGET_ENVIRONMENT_ID
Note

Should the parameters not be provided in the command line, the squid deploy command will read them from the .env file.