Ready to install Swifti? then follow the user guide of the automatic CLI tool.
Run the following command in your terminal to start our handy install wizard:
npm create swifti@latest
When you run the automatic installation tool it will ask you for the name of the project and if you want to use typescript or javascript.
At the end, it will create the necessary structure in the project directory to start working with Swifti.
Once the directory is created, navigate to it and run the dependency installer:
cd project-name
npm install
Once the dependencies are installed, your project will be ready to start working on it:
npm run dev
This will begin with development mode where the changes will be reflected almost immediately.
If you want to install Swifti step by step, check our step-by-step guide:
mkdir project-name
cd project-name
npm init --yes
npm install swifti
If you use typescript you must also install the following:
npm install typescript -D
mkdir src/routes
This is necessary for Swifti to function properly.
// src/lib/route.js
const { Route } = require("swifti")
const route = new Route()
module.exports = { route }
// src/lib/route.ts
import { Route } = from "swifti"
export const route = new Route()
// src/routes/route.js
const { route } = require("../lib/route.js");
module.exports = {
GET: route.handle((ctx) => {
ctx.res.json({
message: "Hello from swifti.",
});
}),
};
// src/routes/route.ts
import { route } from "../lib/route.ts";
export const GET = route.handle((ctx) => {
ctx.res.json({
message: "Hello from swifti.",
});
});
import { defineConfig } from "swifti";
export default defineConfig({
port: 3000,
format: "cjs",
bundle: true,
});
// package.json
{
"scripts": {
"dev": "swifti",
"build": "swifti build"
}
}
npm run dev