Learn full-stack web development using fastn in a week
Learn Now
Frontend
->
Create fastn package

Create a fastn package

fastn is also a ftd package manager. A package contains all related and necessary files. fastn manages the packages and modules for ftd and consists of command line tool fastn.

To get started, you need to install fastn. Refer to the install fastn page to learn how to install fastn.

Create a package

There are two ways to create a fastn package:
Using Command (Recommended)
Manual

Using Command

The simplest way to create a fastn package is to use the command line tool. Suppose you want to create a package named hello-fastn, you need to follow these steps:
create-package
fastn create-package hello-fastn
Lang:
sh
The above command will create a folder named hello-fastn containing two files: FASTN.ftd and index.ftd. You can view the contents of this folder in a text editor such as SublimeText.

Serving the package

After creating the package as described above, you can start the HTTP server. Follow these steps:
go to the package location
cd hello-fastn
Lang:
sh
  • Once you are in the package location, run the following command to start the HTTP server:
serve
fastn serve
Lang:
sh
After starting the HTTP server, open any web browser and type "http://127.0.0.1:8000" into the URL bar. Voila! You can now view your "hello world" page in the browser.

FASTN.ftd

FASTN.ftd is a configuration file where we set configuration for the package.

In FASTN.ftd, the code should look like this:
FASTN.ftd
-- import: fastn

-- fastn.package: hello-fastn
Lang:
ftd
In the code above, we set the package name ashello-fastn.

index.ftd

index.ftd is the index page of your package. You can think of the index page as being the home or default page of your package.

In index.ftd, the code should look like this:
index.ftd
-- ftd.text: Hello World
Lang:
ftd
In the code above, we added a kernel component ftd.text and passed Hello World as the value for text property.