> ## Documentation Index
> Fetch the complete documentation index at: https://canvacord.neplex.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get started with Canvacord

## Setup your development environment

To get started with Canvacord, you need to have a few things set up on your local machine.

* [Node.js](https://nodejs.org/en/download/): Canvacord is built on Node.js, so you need to have it installed on your machine.
* [NPM](https://www.npmjs.com/get-npm): NPM is the package manager for Node.js. You will need it to install Canvacord and its dependencies.
* Optionally [TypeScript](https://www.typescriptlang.org/download): To get the best out of Canvacord, we recommend you use TypeScript, but it's not required.

### Installation

```bash npm theme={null}
npm i canvacord
```

```bash yarn theme={null}
yarn add canvacord
```

```bash pnpm theme={null}
pnpm add canvacord
```

```bash bun theme={null}
bun add canvacord
```

### Use it in your project

You can use Canvacord with or without JSX. JSX is a syntax extension for JavaScript that looks similar to HTML. It allows you to write HTML-like code in your JavaScript files. If you're familiar with React, you'll feel right at home with JSX.

> [tab] With JSX
>
> #### Using Canvacord with JSX
>
> ```jsx ES Modules theme={null}
> /** @jsx JSX.createElement */
> /** @jsxFrag JSX.Fragment */
>
> // The JSX pragma tells transpiler how to transform JSX into the equivalent JavaScript code
>
> // import Canvacord
> // Builder = The base class for creating custom builders
> // JSX = The JSX pragma for creating elements
> // Font = The Font class for loading custom fonts
> // FontFactory = The FontFactory for managing fonts
> import { Builder, JSX, Font, FontFactory } from "canvacord";
> import { writeFile } from "node:fs/promises";
>
> // define a builder
> class Generator extends Builder {
>   constructor() {
>     // set the size of the image
>     super(300, 300);
>
>     // if no fonts are loaded, load the default font
>     if (!FontFactory.size) Font.loadDefault();
>   }
>
>   async render() {
>     // declare the shape of the image
>     return (
>       <div
>         style={{
>           display: "flex",
>           alignItems: "center",
>           justifyContent: "center",
>           backgroundColor: "white",
>           width: "100%",
>           height: "100%",
>         }}
>       >
>         <h1>Hello, World!</h1>
>       </div>
>     );
>   }
> }
>
> // create an instance of the builder
> const generator = new Generator();
> // build the image and save it to a file
> const image = await generator.build({ format: "png" });
>
> await writeFile("image.png", image);
> ```
>
> ```jsx CommonJS theme={null}
> /** @jsx JSX.createElement */
> /** @jsxFrag JSX.Fragment */
>
> // The JSX pragma tells transpiler how to transform JSX into the equivalent JavaScript code
>
> // import Canvacord
> // Builder = The base class for creating custom builders
> // JSX = The JSX pragma for creating elements
> // Font = The Font class for loading custom fonts
> // FontFactory = The FontFactory for managing fonts
> const { Builder, JSX, Font, FontFactory } = require("canvacord");
> const { writeFile } = require("node:fs/promises");
>
> // define a builder
> class Generator extends Builder {
>   constructor() {
>     // set the size of the image
>     super(300, 300);
>
>     // if no fonts are loaded, load the default font
>     if (!FontFactory.size) Font.loadDefault();
>   }
>
>   async render() {
>     // declare the shape of the image
>     return (
>       <div
>         style={{
>           display: "flex",
>           alignItems: "center",
>           justifyContent: "center",
>           backgroundColor: "white",
>           width: "100%",
>           height: "100%",
>         }}
>       >
>         <h1>Hello, World!</h1>
>       </div>
>     );
>   }
> }
>
> async function main() {
>   // create an instance of the builder
>   const generator = new Generator();
>   // build the image and save it to a file
>   const image = await generator.build({ format: "png" });
>
>   await writeFile("image.png", image);
> }
>
> main();
> ```

> [tab] Without JSX (Vanilla)
>
> #### Using Canvacord without JSX
>
> ```js ES Modules theme={null}
> // import Canvacord
> // Builder = The base class for creating custom builders
> // JSX = The JSX pragma for creating elements
> // Font = The Font class for loading custom fonts
> // FontFactory = The FontFactory for managing fonts
> import { Builder, JSX, Font, FontFactory } from "canvacord";
> import { writeFile } from "node:fs/promises";
>
> // define a builder
> class Generator extends Builder {
>   constructor() {
>     // set the size of the image
>     super(300, 300);
>
>     // if no fonts are loaded, load the default font
>     if (!FontFactory.size) Font.loadDefault();
>   }
>
>   async render() {
>     // declare the shape of the image
>     return JSX.createElement(
>       "div",
>       {
>         style: {
>           display: "flex",
>           alignItems: "center",
>           justifyContent: "center",
>           backgroundColor: "white",
>           width: "100%",
>           height: "100%",
>         },
>       },
>       JSX.createElement("h1", null, "Hello, World!")
>     );
>   }
> }
>
> // create an instance of the builder
> const generator = new Generator();
> // build the image and save it to a file
> const image = await generator.build({ format: "png" });
>
> await writeFile("image.png", image);
> ```
>
> ```js CommonJS theme={null}
> // import Canvacord
> // Builder = The base class for creating custom builders
> // JSX = The JSX pragma for creating elements
> // Font = The Font class for loading custom fonts
> // FontFactory = The FontFactory for managing fonts
> const { Builder, JSX, Font, FontFactory } = require("canvacord");
> const { writeFile } = require("node:fs/promises");
>
> // define a builder
> class Generator extends Builder {
>   constructor() {
>     // set the size of the image
>     super(300, 300);
>
>     // if no fonts are loaded, load the default font
>     if (!FontFactory.size) Font.loadDefault();
>   }
>
>   async render() {
>     // declare the shape of the image
>     return JSX.createElement(
>       "div",
>       {
>         style: {
>           display: "flex",
>           alignItems: "center",
>           justifyContent: "center",
>           backgroundColor: "white",
>           width: "100%",
>           height: "100%",
>         },
>       },
>       JSX.createElement("h1", null, "Hello, World!")
>     );
>   }
> }
>
> async function main() {
>   // create an instance of the builder
>   const generator = new Generator();
>   // build the image and save it to a file
>   const image = await generator.build({ format: "png" });
>
>   await writeFile("image.png", image);
> }
>
> main();
> ```

## Result of the above code

![canvacord-quickstart-output](https://mintcdn.com/neplex-79/2b3htIeXA4_HHvsZ/images/assets/canvacord-quickstart-output.png?fit=max\&auto=format\&n=2b3htIeXA4_HHvsZ\&q=85\&s=71ff6de098b684a0e3cb929d5f14faa6)

## Further reading

To learn more about Canvacord, check out the following resources:

> [card] [Image Generation](https://canvacord.neplex.dev/builders/introduction-to-builders.md)
>
> Learn how to generate custom images using Canvacord's builder api.

> [card] [Image Manipulation](https://canvacord.neplex.dev/image-manipulation/image-manipulation-api.md)
>
> Learn how to manipulate images using Canvacord's built-in image manipulation
> utilities.

> [card] [Built-in image builders](https://canvacord.neplex.dev/builders/builtin-builders)
>
> Use Canvacord's built-in builders to create commonly used images quickly, such
> as rank cards, leaderboard images, and more.

> [card] [Built-in image manipulators](https://canvacord.neplex.dev/image-manipulation/builtin-apis.md)
>
> Use Canvacord's built-in builders to generate commonly used memes, such as
> triggered gif, jail image, and more.

> [card] [Looking for examples?](https://canvacord.neplex.dev/examples/introduction.md)
>
> Find a list of builder examples that you can copy and paste into your project.

> [card] [Have a suggestion?](https://github.com/neplextech/canvacord/issues)
>
> Create an issue on GitHub if you have a suggestion or found a bug in
> Canvacord.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.