- v17.6Latest
- v17.5
- v17.4
- v17.3
- v17.2
- v17.1
- v17.0
- v16.9
- v16.8
- v16.7
- v16.6
- v16.5
- v16.4
- v16.3
- v16.2
- v16.1
- v16.0
- v15.8
- v15.7
- v15.6
- v15.5
- v15.4
- v15.3
- v15.2
- v15.1
- v15.0
- v14.9
- v14.8
- v14.7
- v14.6
- v14.5
- v14.4
- v14.3
- 14.2
- v14.1
- v14.0
- v13.9
- v13.8
- v13.7
- v13.6
- v13.5
- v13.4
- v13.3
- v13.2
- v13.1
- v13.0
- v12.9
- v12.8
- v12.7
- v12.6
- v12.5
- v12.4
- v12.3
- v12.2
- v12.1
- v12.0
- v11.9
- v11.8
- v11.7
- v11.6
- v11.5
- v11.4
- v11.3
- v11.2
- v11.1
- v11.0
- v10.9
- v10.8
- v10.7
- v10.6
- v10.5
- v10.4
- v10.3
- v10.2
- v10.1
- v10.0
- v9.9
- v9.8
- v9.7
- v9.6
- v9.5
- 9.4
- v9.3
- v9.2
- v9.1
- v9.0
- v8.9
- v8.8
- v8.7
- v8.6
- v8.5
- v8.4
- v8.3
- v8.2
- v8.1
- v8.0
- v7.9
- v7.8
- v7.7
- v7.6
- v7.5
- v7.4
- v7.3
- v7.2
- v7.1
- v7.0
- v6.9
- v6.8
- v6.7
- v6.6
- v6.5
- v6.4
- v6.3
- v6.2
- v6.1
- v6.0
- v5.9
- v5.8
- v5.7
- v5.6
- v5.5
- v5.4
- v5.3
- v5.2
- v5.1
- v5.0
- v4.9
- v4.8
- v4.7
- v4.6
- v4.5
- v4.4
- v4.3
- v4.2
- v4.1
- v4.0
- v3.9
- v3.8
- v3.7
- v3.6
- v3.5
- v3.4
- v3.3
- v3.2
- v3.1
- v3.0
- v2.9
- v2.8
- v2.7
- v2.6
- v2.5
- v2.4
- v2.3
- v2.2
- v2.1
- v2.0
- v1.9
- v1.8
- v1.7
- v1.6
- v1.5
- v1.4
- v1.3
- v1.2
- v1.1
- v1.0
faster_react
It is a complete framework, with automatic compilation of components for the
client side, Server Side Rendering, Hydration and interactive client-side
components. Fully compatible with Deno Deploy. It has folders in its structure
for automatic inclusion of pages, routes, components and static files. It has
automatic reload client side and compilation when "dev":true
in
options.json
. There is also automatic generation of routes based on the file
and folder structure. It focuses on performance and practicality. 100% Deno, no
Node dependencies.
About Faster, it is an optimized middleware server with an absurdly small amount of code (300 lines) built on top of Deno’s native HTTP APIs with no dependencies. It also has a collection of useful middlewares: log file, serve static, CORS, session, rate limit, token, body parsers, redirect, proxy and handle upload. Fully compatible with Deno Deploy. In “README” there are examples of all the resources. Faster’s ideology is: all you need is an optimized middleware manager, all other functionality is middleware. See more at: https://github.com/hviana/faster
Contents
- Benchmarks
- Architecture
- App structure
- Packages included
- Creating a project
- Running a project
- Deploy
- References
- About
Benchmarks
It has 0.9% of the code quantity of Deno Fresh. Benchmanrk command:
git clone https://github.com/denoland/fresh.git
cd fresh
git ls-files | xargs wc -l
# 104132 on version 1.7.1
git clone https://github.com/hviana/faster_react.git
cd faster_react
git ls-files | xargs wc -l
# 1037 on version 8.5
Architecture
This framework uses Headless Architecture [1] to build the application as a whole. Along with this, the Middleware Design Pattern [2] is used to define API routes in the Backend. Headless Architecture gives complete freedom to the developer. This freedom reduces the learning curve of the framework. Despite the freedom, there is an explicit separation between Backend and Frontend. This explicit separation helps programmers. In addition to this, the Middleware Design Pattern is very practical and simple for defining API routes.
App structure
All these application folders are inside the app
folder. Remember that any
change in these folders will cause the framework to compile, cache, and deliver
everything automatically to the client, also updating server-side resources.
There is no need to restart the application.
frontend_pages folder
- Use only frontend libraries here.
- You can organize your files into subdirectories here.
- The
.tsx
extension is used here. - These pages are rendered on the server and hydrated on the client.
- Routes to these pages are generated automatically. For example, the path
localhost:8080/pages/checkout/cart
refers to the fileapp/frontend_pages/checkout/cart.tsx
. It is important to note that the initial route will point toapp/frontend_pages/index.tsx
(ex:localhost:8080
=>app/frontend_pages/index.tsx
). - This file must have a default export with the React Function/Component.
- The properties passed to the page includes:
- Form-submitted data (or JSON POST);
- URL search parameters, such as
/pages/myPage?a=1&b=2
will result in{a:1, b:2}
; options.json => framework
;backend_pages_props
manipulations;- Request headers within the
headers
key.
frontend_components folder
- Use only frontend libraries here.
- You can organize your files into subdirectories here.
- The
.tsx
extension is used here. - This file must have a default export with the React Function/Component.
frontend_scripts folder
- Use only frontend libraries here.
- You can organize your files into subdirectories here.
- Here the extension
.ts
and.js
is used. - You are free to make as many exports or calls (including asynchronous) as you
want here. Different from
frontend_pages
frontend_components
, the scripts here are not automatically delivered to the client. They need to be imported by thefrontend_components
orfrontend_pages
. The intention here is to group common functions/objects for React Functions/Components, such as form field validations. You can also havefrontend_scripts
in common for otherfrontend_scripts
.
css folder
Application css style files.
- You can have multiple CSS files and they are automatically compiled.
- You can organize your files into subdirectories here.
static folder
Files that will be served statically. Routes are generated automatically based
on the folder and file structure, for example
localhost:8080/static/favicon.ico
will match the file
app/static/favicon.ico
.
backend_api folder
- You can import your backend libraries here.
- You can organize your files into subdirectories here.
- The
.ts
extension is used here. - The file and folder structure is free here and does not influence anything.
- Here you are also free to define the routes in whatever pattern you want.
- This file must have a default export with the function (which can be asynchronous).
- This function has as input parameter an instance of Server of faster.
- You can do your backend manipulations here. For example, getting data from the database. Including asynchronous calls.
- Define your custom api routes. For help, see: https://github.com/hviana/faster
backend_pages_props folder
- You can import your backend libraries here.
- You can organize your files into subdirectories here.
- The
.ts
extension is used here. - Each of these files must have the same folder structure and name as the
corresponding page, with the difference in the extension, which here is .ts.
For example
app/frontend_pages/checkout/cart.tsx
should have as a corresponding (if one exists)app/backend_pages_props/checkout/cart.ts
here. - This file must have a default export with the function (which can be asynchronous) that will handle the props that will be passed to the page.
- This function has as input parameter the props that will be passed to the page.
- Only use JSON serializable data inside props.
- You can do your backend manipulations here. For example, getting data from the database. Including asynchronous calls.
backend_files folder
- You can import your backend libraries here.
- You can organize your files into subdirectories here.
- The
.ts
extension is used here. - You are free to make as many exports or calls (including asynchronous) as you want here.
- The intention here is to group common functions/objects for
backend_api
,backend_pages_props
(andbackend_files
, since you may havebackend_files
in common for otherbackend_files
) files, such as user validations.
Packages included
There are several packages included to help you develop React applications. Here
are some examples of imports
that you can use without configuring anything:
import {/* your imports */} from "react";
import {/* your imports */} from "react/";
import {/* your imports */} from "react-dom";
import {/* your imports */} from "react-dom/server";
import {/* your imports */} from "react-dom/client";
import {/* your imports */} from "react-router-dom";
import {/* your imports */} from "react-router";
import {/* your imports */} from "react/jsx-runtime";
import {/* your imports */} from "render";
import {/* your imports */} from "htm/react";
/*
About Faster, it is an optimized middleware server with an absurdly small amount
of code (300 lines) built on top of Deno's native HTTP APIs with no
dependencies. It also has a collection of useful middlewares: log file, serve
static, CORS, session, rate limit, token, body parsers, redirect, proxy and
handle upload. Fully compatible with Deno Deploy. In "README" there are examples
of all the resources. Faster's ideology is: all you need is an optimized
middleware manager, all other functionality is middleware. See more at:
https://deno.land/x/faster
*/
import {/* your imports */} from "faster";
/*
Deno KV file system, compatible with Deno deploy. Saves files in 64kb chunks.
You can organize files into directories. You can control the KB/s rate for
saving and reading files, rate limit, user space limit and limit concurrent
operations, useful for controlling uploads/downloads. Makes use of Web Streams
API. See more at: https://deno.land/x/deno_kv_fs
*/
import {/* your imports */} from "deno_kv_fs";
Creating a project
You can simply download this repository. There is also the command, which
requires the git command installed and configured. Command:
deno run -A -r "https://deno.land/x/faster_react/new.ts" myProjectFolder
. You
can make your customizations and configure the server in options.json
.
Running a project
It is necessary to execute the command: deno task serve
Deploy
- Make sure your project is in your own GIT repository.
deno install -A jsr:@deno/deployctl
- Delete
deno.lock
to prevent problems. Be careful that it is often recreated automatically. You may need to close the IDE and close the Deno process. deployctl deploy
- Remember that for production the option has to be
framework => "dev":false"
inoptions.json
.
References
[1] Dragana Markovic, Milic Scekic, Alessio Bucaioni, and Antonio Cicchetti. 2022. Could jamstack be the future of web applications architecture? an empirical study. In Proceedings of the 37th ACM/SIGAPP Symposium on Applied Computing (SAC ’22). Association for Computing Machinery, New York, NY, USA, 1872–1881. DOI: https://doi.org/10.1145/3477314.3506991
[2] Brown, Ethan. Web development with node and express: leveraging the JavaScript stack. O’Reilly Media, 2019. URL: http://www.oreilly.com/catalog/9781492053484
About
Author: Henrique Emanoel Viana, a Brazilian computer scientist, enthusiast of web technologies, cel: +55 (41) 99999-4664. URL: https://sites.google.com/view/henriqueviana
Improvements and suggestions are welcome!