Quick Start
Get started with Flux quickly by following these simple steps to set up your environment and run your first command.
Prerequisites
Before you begin, ensure you have the following prerequisites:
- Installed Flux on your system
- Node.js 16.0.0 or later
- Basic familiarity with package managers and the command line
Creating a New Project
Create a New Project Directory
Let's start by creating a new project with Flux. Open your terminal and run the following command:
flux init my-projectThis command creates a new directory called my-project with a basic project structure and a default flux.config.js file.
Navigate to Your Project Directory
Change into your project directory by running:
cd my-projectProject Structure
The basic project structure created by Flux looks like this:
The flux.config.js file contains the configuration for your Flux project. You can customize this file to suit your needs.
Installing Dependencies
Let's add some dependencies to our project. With Flux, you can use the add command to install packages:
flux add react react-domThis command installs the React and React-DOM packages and adds them to your project's dependencies.
Running Scripts
Add a Script to Your Project
You can add scripts to your project by modifying the package.json file. For example, you can add a script to start your development server:
{
"scripts": {
"dev": "tsx src/index.ts",
"build": "tsx src/index.ts --build"
}
}Start the Development Server
To start your project, you can use the run command. For example, to start a development server, run:
flux run devThis command starts the development server.
Build Your Project
To build your project for production, you can run:
flux run buildThis command compiles your project and prepares it for deployment.
Common Commands
Here are some common Flux commands you can use:
Install packages using Flux
flux install <package-name> Install all dependencies listed in your package.json:
flux installUninstall packages using Flux
flux uninstall <package-name>Uninstall all dependencies listed in your package.json:
flux uninstallUpdate package versions using Flux
flux update <package-name>Update all dependencies listed in your package.json:
flux updateRun a script
flux run <script-name>