Skip to main content

🚀 Introduction

  • Before getting started, you can choose to use the Deno runtime in your project. If you don’t have Deno installed locally yet, you have two main options:
  • Install via npm (recommended for compatibility with npx during deploy):
npm install deno
  • Or install Deno via the official installer (check Deno documentation for native installation instructions).
  • By adding deno as a dependency, you can use npx deno in the START field of squarecloud.app to start your application with Deno. See below in the “Starting the Application” section for START examples.
  • Next, you will need to create an account on Square Cloud, which can be done through the login page. You can use your email, GitHub, or both to create the account.
  • Finally, you need to have an active paid plan on your account. You can view our plans and purchase one according to your needs here.

⚙️ squarecloud.app file configuration

Learn more: how to create the configuration file for Square Cloud.

The squarecloud.app file is a configuration file that will be used to configure your application; it will serve to define the name, description, version, main file, among other things.
If you are uploading your application via the Square Cloud website, you can ignore this section. The site automatically creates the squarecloud.app configuration file for you.

▶️ How to start your application

  • To use the Deno runtime in the Square Cloud Node.js environment, first add the deno package to your project (e.g. npm install deno) so that the npx deno command is available in the runtime environment.
  • Then, set the START field in your squarecloud.app with the command that starts your application using Deno. Examples:
OR .config
START=npx deno run --allow-net --allow-env main.ts
If you use tasks defined in deno.json, you can start like this:
START=npx deno task start
  • Adjust permissions (--allow-net, --allow-env, --allow-read, etc.) according to your application’s needs.
  • Remember: if the START field is defined, the value in it will be executed directly. For more information about configuration file parameters, visit configuration parameters.
  • If you use npm modules with Deno and the node_modules folder does not exist, Square Cloud will run npm install --no-package-lock --no-audit --no-fund to install dependencies and clean the .npm folder.
If you intend to use Deno as a runtime, we recommend adding deno as a dependency (npm install deno) to ensure npx deno is available in the runtime environment during deploy. In projects where you prefer to use the native Deno installer, check compatibility and your build requirements before opting for this approach.

🖥️ Preparing the project

📁 Essential configuration files

When preparing your Deno project for deploy on Square Cloud, ensure you include the configuration file (squarecloud.app/.config) and your application’s essential files inside a zip file.
The configuration file (squarecloud.app/.config) must be located at the root of the zip file. Otherwise, Square Cloud will not be able to find it during deploy.

🗑️ Files to exclude before uploading

  • node_modules: Only necessary if you use npm modules; otherwise, do not upload to reduce upload size.
  • package-lock.json: The production environment will install dependencies based on package.json when npm usage is detected.
  • deno_dir or .cache/deno: Deno cache directory; not needed for deploy.

🤔 Why exclude these files?

There are several reasons to exclude node_modules, package-lock.json, and Deno cache before uploading your project:
  1. Installation Consistency: Not uploading node_modules ensures dependencies are installed by the production environment, resulting in a consistent build free of local system discrepancies.
  2. Updated Installations: The production environment will install the latest compatible versions of dependencies listed in package.json (when applicable) or use remote imports defined in deno.json.
  3. Upload Size Reduction: Not including these directories reduces the uploaded file size, speeding up the upload process and making the deploy more efficient.
By doing this, you ensure your Deno application is optimally prepared for hosting on Square Cloud.

📄 Required Files

Three files are necessary to host your Deno project:
  • squarecloud.app/.config
  • mainFile.ts/.js (Example of main file)
  • deno.json or deno.jsonc (definition of permissions and tasks). If using npm modules, also include package.json.

💡 Troubleshooting

This error occurs when the file defined as “main” for your application in the configuration file does not exist, is spelled incorrectly, or the path is wrong. If your main file is inside a folder, for example, you must inform folder/file.ts or folder/file.js.
The minimum amount of RAM required to host a bot is 256MB and for a site/API it is 512MB. However, depending on the size and complexity of your application, it may be advisable to allocate a larger amount of RAM to avoid the LACK_OF_RAM error.

📤 How to host your project

Now that you have prepared all the files for your Deno project, the next step is to upload them to Square Cloud and put your application online. There are several ways to upload, but we will cover two: via Dashboard or via CLI.

Via dashboard

1

Access the Upload Page

Access the upload page and upload your project zip file.
2

Configure Your Environment

After uploading your zip, you will need to configure the name, main file or runtime environment and other settings for your project.
If you are uploading a web project, make sure to select "Web Publication" and set a subdomain to your project.
3

Deploy Your Project

Finally, click on the "Deploy" button to host your project on Square Cloud.
After deployment, you can monitor your project's status and logs from the dashboard.

Via CLI

To use this method, you need to create a config file named squarecloud.app in the root directory of your project. This file will contain the necessary configuration for your project.

Learn more about: how to create the configuration file for Square Cloud.

The squarecloud.app file is a configuration file that will be used to configure your application; it will be used to define your environment.
1

Install the CLI

First, you need to have the CLI installed in your environment. If you don't have it yet, run the following command in your terminal:
npm install -g @squarecloud/cli
If you already have it, we recommend updating it. To do this, run the following command in your terminal:
squarecloud update
2

Authenticate

Now, to authenticate and use other CLI commands, you will find your authorization key here by clicking on "Request API Key". After obtaining your authorization key, run the following command:
squarecloud auth login
3

Upload Your Project

Finally, to deploy your application to Square Cloud using the CLI, you need to run the following command:
squarecloud upload 
Or if you created the zip manually, you can use:
squarecloud upload --file <path/to/zip> 

Contact us

If you continue facing technical difficulties, our specialized support team is available to assist you. Contact us and we'll be happy to help you resolve any issue.