Tnf, the north face, the next framework. Tnf is focused on simple, performance and developer experience. Framework should be simple. CSR development should be simple. Type safety should be built-in.
Please consider following this project’s author, sorrycc, and consider starring the project to show your ❤️ and support.
Features
Simple, performance and developer experience focused.
Type safety built-in.
TanStack Router built-in.
Conventional global style with src/global.{less,css}.
In addition to supporting numbers, delay also supports string ranges, such as delay: ‘500-1000’, which randomly selects a value between 500ms and 1000ms.And allowing the configuration to be overridden by the url parameter, such as /api/users?delay=3000.
mountElementId
Type: string
Default: 'root'
The mount element id.
plugins
Type: Plugin[]
Default: []
The plugins configuration. Checkout plugin.md for more details.
@umijs/tnf
Tnf,
the north face, the next framework. Tnf is focused on simple, performance and developer experience. Framework should be simple. CSR development should be simple. Type safety should be built-in.Features
src/global.{less,css}.src/client.tsx.Getting Started
Create a new project with the following command:
Then you can generate a page with the following command.
Then you can start the development server or build the project. After building, you can preview the product locally.
Commands
tnf build: Build the project.tnf chat --message=<message> --model=<model> --verbose: Chat with AI assistant.tnf config list/get/set/remove [name] [value]: Manage the config.tnf dev: Start the development server.tnf doctor: Check the project for potential issues.tnf generate/g <type> <name>: Generate a new page (or component and other types in the future).tnf preview: Preview the product after building the project.tnf sync --mode=<mode>: Sync the project to the temporary directory.tnf version: Print the version of tnf.API
@umijs/tnf: The entry of tnf, includingdefineConfig, …@umijs/tnf/router: The router module, reexported from@tanstack/react-router.@umijs/tnf/ssr: The ssr module, includingMeta,ClientandServer.@umijs/tnf/ai: The ai module, includingtools.Config
Config is loaded from
.tnfrc.tsby default.alias
[string, string][][]Alias is used to replace the values in
importstatements. These values are passed to bundlers and TypeScript automatically.NOTICE: You will need to run
tnf devto have the alias configuration intsconfig.jsonautomatically generated.bundler
'webpack' | 'mako''mako'The bundler to use.
NOTICE: webpack bundler is not implemented yet.
clickToComponent
{ editor?: 'vscode' | 'vscode-insiders' | 'cursor' } | falsefalseClick the component to open in the editor.
devServer
{ port?: number; host?: string; https?: { hosts?: string[] }; ip?: string }{ port: 8000, host: 'localhost' }The development server configuration.
doctor
{ phantomDeps?: { exclude?: string[] } }{}The doctor configuration.
externals
Record<string, string>{}An object that maps package names to their corresponding paths.
less
{ modifyVars?: Record<string, string>; globalVars?: Record<string, string>; math?: 'always' | 'strict' | 'parens-division' | 'parens' | 'strict-legacy' | number; sourceMap?: any; plugins?: (string | [string, Record<string, any>])[];}{}The configuration passed to lessLoader.
mock
{ delay?: string | number }{ delay: 0 }In addition to supporting numbers, delay also supports string ranges, such as delay: ‘500-1000’, which randomly selects a value between 500ms and 1000ms.And allowing the configuration to be overridden by the url parameter, such as /api/users?delay=3000.
mountElementId
string'root'The mount element id.
plugins
Plugin[][]The plugins configuration. Checkout plugin.md for more details.
publicPath
string/The publicPath configuration.
reactCompiler
{ target?: '17' | '18' | '19'; sources?: (filePath: string) => boolean }falseEnable react compiler for better performance.
reactScan
{}falseEnable react scan to detects performance issues in your React code.
router
{ defaultPreload?: 'intent' | 'render' | 'viewport'; defaultPreloadDelay?: number; devtool?: { options?: { initialIsOpen?: boolean; position?: 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right' }; } | false; convention?: any }{ defaultPreload: 'intent', defaultPreloadDelay: 100 }The router configuration. Checkout @tanstack/router-generator for convention config.
ssr
{ renderMode?: 'stream' | 'string' }{ renderMode: 'stream' }The ssr configuration.
Environment Variables
Environment variables are used to override the config.
PORT: The port to use.HOST: The host to use.FAQ
How to specify a redirect route?
You can use
redirectfunction in loader to specify a redirect route.How to get the loader data from parent route?
First, define parent route with
beforeLoad.If it’s root route, you can use
createRootRouteWithContextinstead.Second, fetch the loader data in child route with
context.CREDITS
This project is inspired by:
LICENSE
MIT