Installation
Requirements:
- TypeScript 5.4 or newer.
- Node.js, Deno, and Bun are supported.
To quickly set up a new Effect application, we recommend using create-effect-app
, which will handle all configurations for you. To create a new project, run:
Once you complete the prompts, create-effect-app
will create a folder with your project name and install all required dependencies.
For more details on the CLI, see the Create Effect App documentation.
Follow these steps to create a new Effect project for Node.js:
-
Create a project directory and navigate into it:
-
Initialize a TypeScript project:
This creates a
package.json
file with an initial setup for your TypeScript project. -
Initialize TypeScript:
When running this command, it will generate a
tsconfig.json
file that contains configuration options for TypeScript. One of the most important options to consider is thestrict
flag.Make sure to open the
tsconfig.json
file and verify that the value of thestrict
option is set totrue
. -
Install the necessary package as dependency:
This package will provide the foundational functionality for your Effect project.
Let’s write and run a simple program to ensure that everything is set up correctly.
In your terminal, execute the following commands:
Open the index.ts
file and add the following code:
Run the index.ts
file. Here we are using tsx to run the index.ts
file in the terminal:
You should see the message "Hello, World!"
printed. This confirms that the program is working correctly.
Follow these steps to create a new Effect project for Deno:
-
Create a project directory and navigate into it:
-
Initialize Deno:
Let’s write and run a simple program to ensure that everything is set up correctly.
Open the main.ts
file and replace the content with the following code:
Run the main.ts
file:
You should see the message "Hello, World!"
printed. This confirms that the program is working correctly.
Follow these steps to create a new Effect project for Bun:
-
Create a project directory and navigate into it:
-
Initialize Bun:
When running this command, it will generate a
tsconfig.json
file that contains configuration options for TypeScript. One of the most important options to consider is thestrict
flag.Make sure to open the
tsconfig.json
file and verify that the value of thestrict
option is set totrue
. -
Install the necessary package as dependency:
This package will provide the foundational functionality for your Effect project.
Let’s write and run a simple program to ensure that everything is set up correctly.
Open the index.ts
file and replace the content with the following code:
Run the index.ts
file:
You should see the message "Hello, World!"
printed. This confirms that the program is working correctly.
Follow these steps to create a new Effect project for Vite + React:
-
Scaffold your Vite project, open your terminal and run the following command:
This command will create a new Vite project with React and TypeScript template.
-
Navigate into the newly created project directory and install the required packages:
Once the packages are installed, open the
tsconfig.json
file and ensure that the value of thestrict
option is set to true. -
Install the necessary package as dependency:
This package will provide the foundational functionality for your Effect project.
Now, let’s write and run a simple program to ensure that everything is set up correctly.
Open the src/App.tsx
file and replace its content with the following code:
After making these changes, start the development server by running the following command:
Then, press o to open the application in your browser.
When you click the button, you should see the counter increment. This confirms that the program is working correctly.