@iamendor/next-cli
v1.0.9
Published
A powerful CLI to create Next.js templates
Downloads
8
Readme
Next.js CLI
A powerful CLI to create Next.js templates
Version: 1.0.8
I created this tool, because my stack is Nest.js and Next.js, and I wanted to create a CLI tool for Next.js like Nest. Currently works as a standalone package, but I am planning to integrate the official next cli into this tool.
Documentation
Installation
npm install -g @iamendor/next-cli
Quick start
You can create a configuration file to configure the cli.
next init config
The CLI does not require to use the configuration file, but I recommend to configure it per project to configure the extension, styling and etc. See the example configuration file here.
Commands
Init
Config
Initialize configuration file
Generate
Generate Next.js templates, in every subcommand you have to specify a path and also you can specify extension, if you specify it in the command line, the configuration file arguments will be overriden. If you want to use typescript, specify --ts flag in command route and middleware or --tsx in command module, page, loading, error, layout, notfound and component
Module
next generate module <path>
Generate a Next.js module, this includes a page, loading, error, and not found pages, you can also include a layout file, creates a style file for every file.
Flags
--layout
- create layout file--error
,--no-error
- create error file--loading
,--no-loading
- create loading file--not-found
,--no-not-found
- create not found file--style
,--no-style
- specify style files, available options: css, scss, or if you want to use tailwind specify--no-style
flag, you can also specify--scss
flag to use scss as styling--merge-styles
- create one style file--type
- specify the route type, available options: default, dynamic, parallel, intercepting, if you want to create these type of route specify it in the flag, do not use in the path, it gives an error, this can be a future feature. You can also specify it with prefixed flags like--dynamic
,--parallel
,--intercepting
--level
- if you use--intercepting
flag, specify the level of the interception, available options: 0, 1, 2, root
Page
next generate page <path>
Generate a page file
Flags
Layout
next generate layout <path>
Generate a layout file
Flags
Error
next generate error <path>
Generate an error file
Flags
Loading
next generate loading <path>
Generate an loading file
Flags
Not found
next generate notfound <path>
Generate a not found file
Flags
Component
next generate component <path>
Generate a component file, unlike the router components, this file is generated by the last part of the path, so if you provide g c foo/bar
, this creates foo/Bar.jsx
Flags
Route
next generate route <path>
Generate a route file
Flags
--type
- see in module, available options: default, dynamic, flag--dynamic
is also available--handlers
- List of handlers to create, available options: GET, POST, PUT, PATCH, DELETE. You can also specify--GET
,--POST
flags to add these handlers--single-handler
- Create a global handler for route
Middleware
next generate middleware <path>
Generate a middleware file
Flags
--matcher
- specify matcher for the middleware, see the usage here--global
- make the middleware global