Skip to main content

Set up the backend

Out of the box, Squid hosts a backend to connect your client and your data sources.
Squid's built-in database features are fully functional without needing to customize this backend beyond setting up security rules.

The Squid backend is the heart of your Squid application. It contains the logic that dictates how your app integrates with data sources, APIs, and services. While your app might have a single frontend, multiple frontends, or even only integrations with server-side features and no frontend, running locally or deploying the Squid backend is always required to use Squid Cloud.

Project setup

If you haven't done so already, create a new Squid app in the Squid Cloud Console. You can check out the steps to create the app here.

Create a new directory for your project and change to the new directory. This directory will contain the frontend and backend projects.

mkdir my-app
cd my-app

Backend initialization

The following steps generate a Squid backend project.

Console initialization

  1. Go to your application overview page in the Squid Console and scroll to the Backend project section. Click the Initialize backend button.

  2. Follow the steps there to install the Squid Cloud CLI and generate a backend project. We recommended that your backend project reside near your client project to keep things organized.

  3. Change to your newly generated backend directory (named YOUR_APP_NAME-backend):

cd YOUR_APP_NAME-backend
  1. Run your backend project locally using the following command:
squid start

Alternatively, you can deploy your Squid backend by following the steps described in the console. Deploying the backend is not required for this quickstart. The squid deploy command deploys your Squid backend in its current state. Whenever you make changes to the backend, you will need to redeploy. For more information on local and deployed Squid backends, view the documentation on environments.

Your backend is now configured and ready to use Squid!

Backend Security

Squid puts security first, meaning Squid's security rules by default deny access to backend resources, including the built-in database.

However, to generate the backend project for this demo, Squid set a security rule that allows all access to the built-in database, which should be adjusted for production applications. You can see this security rule in the /src/service/example-service.ts file located in the backend directory.

To learn more about securing the built-in database and other database integrations in Squid, read about securing data access and the @secureDatabase decorator.

Continue to the next step of the full-stack tutorial by learning about setting up the client with Squid.