Introduction

  • Before you begin, make sure you have Node.js and npm installed on your system. If you don’t have them yet, you can download them from the official Node.js website.
  • Next, you will need to create an account on Square Cloud, which can be done through the sign up page. You can use your email to create an 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.

Setting up Fastify

To use Fastify, you need to install it on your system. Run the following command:

npm install fastify

This command installs the fastify package on your system, which allows you to use Fastify in your terminal.

Creating a Fastify Project

To create a new Fastify project, you can start by creating a new file and writing the following code:

app.js
// Importing the Fastify module
const fastify = require('fastify')({ logger: true });

// Defining a route handler for the route '/'
// This route handler sends 'Hello, World!' when accessed.
fastify.get('/', async (request, reply) => {
  return 'Hello World!';
});

// Making our Fastify application listen on port 80
fastify.listen({ port: 80 })
  .then((address) => {
    // This block of code will run once the server is listening on port 80
    fastify.log.info(`Example app listening at ${address}`);
  })
  .catch((err) => {
    // This block of code will run if there is an error when trying to listen on port 80
    fastify.log.error(err);
    process.exit(1);
  });

Creating the squarecloud config file

Learn about: how to make 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 the name, description, version, main file, among other things.

Configuring the START Field

In the Square Cloud configuration file, the START field is optional and is only necessary if you are using a custom script to start the website or API. In the example provided, the START field is not necessary.

Purchasing a Plan Before Uploading Your Project

Before you can upload your project to Square Cloud, it’s important to understand that you need to purchase a plan. The type of plan you choose will depend on the resources required by your application. You can view our plans here.

Are you wondering how much RAM and CPU your plan needs to host a Fastify application? Don’t worry, we’re here to help. Fastify is a web framework highly focused on providing the best developer experience with the least overhead and a powerful plugin architecture. It’s easy to learn, highly flexible, and suitable for a wide range of applications, making it a great choice for web development. Fastify also has excellent production capabilities, making it a robust choice for building and deploying production-grade applications. It’s designed to be efficient, fast, and lightweight, ensuring your applications run smoothly and reliably. Our Standard plan offers 4GB of RAM and 4vCPU, which should be sufficient for most Fastify applications. However, if you’re working on a larger project or need more stability, we recommend considering our Pro plan. With additional resources, you can ensure smooth performance even under high demand. To purchase, simply click here.

Uploading Project to Square Cloud

After preparing your project files, you can now upload them to Square Cloud and host your project.

Access the Square Cloud Dashboard and upload your project files.

Troubleshooting

Additional Resources

For more information about Fastify and its tools, visit the official Fastify documentation. There, you’ll find detailed guides, tutorials, and API documentation to help you make the most of Fastify.

If you continue to experience any issues, please don’t hesitate to contact our support team.