A simple, easy to use CLI for creating Svelte/SvelteKit components, actions, and routes, quickly and conveniently.
Now with 0 dependencies!
*Find me on NPM!*
- Simple and easy generation of:
- Components
- Routes/Endpoints
- Actions
- Sveltegen handles file structure for you
Note: only run Sveltegen at your project root directory.
Install globally (recommended):
npm install -g sveltegen
...or use npx to skip the install
npx sveltegen
command | description |
---|---|
config |
allows you to change the path to your output folders |
help |
shows all available commands |
action alias: a |
makes a new action |
component alias: c |
makes a new component |
route alias: r |
makes a new route |
Below is a table of what commands have what options.
TypeScript | SCSS | Endpoint | Page | |
---|---|---|---|---|
action |
✅ | ❌ | ❌ | ❌ |
component |
✅ | ✅ | ❌ | ❌ |
route |
✅ | ✅ | ✅ | ✅ |
Don't want to use TypeScript / SCSS? Don't worry, just don't put any -t -s
flags! Sveltegen will create .css
and .js
files, as well as properly format your .svelte
files, if you opt-out of either of them.
sveltegen <command> [options]
For example, to create a new component named Button with SCSS and Typescript:
sveltegen component Button -t -s
// you can use the shorthand format too!
sveltegen c Button -t -s
Components:
[name].svelte
index.ts // or index.js if not using Typescript
index.scss // or index.css if not using SCSS
Routes:
[name]/index.svelte // optional
[name]/index.json.ts // optional ; or index.json.js if not using Typescript
Actions:
[name].ts // or [name].js if not using Typescript