Swytch templates
Swytch provides a collection of official starter templates to help you get up and running with your projects faster. These templates are designed to eliminate the need for repetitive boilerplate setup, letting you jump straight into building your application. Whether you're creating a lean API, a more structured backend, or a server-rendered web application, Swytch's starter templates offer flexible starting points suited to your development needs.
Currently, Swytch has a template pack with three templates:
swytch-api-lite
β A lightweight API template with all routing and logic defined inline in theServer.cs
file. Ideal for small projects and quick prototypes.swytch-api
β A structured API template that separates routing and handler logic, organizing handlers in anActions/
directory.swytch-web
β A web application template pre-configured with Swytch's templating engine and routing capabilities. Perfect for building dynamic server-rendered sites.
Each template reflects a different architectural approach using a playlist application while maintaining Swytchβs simplicity and developer-first philosophy. You can choose the one that fits your use case and evolve your app from there.
Now let's explore them in more detail.
Installation
Installing the Swytch Template Pack
To start using Swytch templates, you first need to install the Swytch template pack from NuGet. This gives you access to all available Swytch starter templates directly through the .NET CLI.
Run the following command:
dotnet new install Swytch.Template.Pack::1.0.0
Usage
creating / starting projects with the templates
Swytch API
dotnet new swytch-api -n MyApi
Sample output π¦
MySwytchApi/
βββ Actions/PlaylistAction.cs
βββ DTOs/AddPlaylist.cs, AddSong.cs
βββ Helpers/DatabaseHelpers.cs
βββ Models/Playlist.cs, Song.cs
βββ Services/
β βββ Interfaces/IPlaylistService.cs
β βββ Implementation/PlaylistService.cs
βββ Statics/index.html, logo-5.png
βββ Server.cs
βββ Swytch-Api-Template.csproj
Swytch API Lite
dotnet new swytch-api-lite -n MyApi
Sample output π¦
MySwytchApi/
βββ DTOs/AddPlaylist.cs, AddSong.cs
βββ Helpers/DatabaseHelpers.cs
βββ Models/Playlist.cs, Song.cs
βββ Services/
β βββ Interfaces/IPlaylistService.cs
β βββ Implementation/PlaylistService.cs
βββ Statics/index.html, logo-5.png
βββ Server.cs
βββ Swytch-Api-Lite-Template.csproj
Swytch Web
dotnet new swytch-web -n MyWebApp
Sample output π¦
MySwytchApi/
βββ Actions/PlaylistAction.cs
βββ DTOs/AddPlaylist.cs, AddSong.cs
βββ Helpers/DatabaseHelpers.cs
βββ Models/Playlist.cs, Song.cs, ViewList.cs
βββ Services/
β βββ Interfaces/IPlaylistService.cs
β βββ Implementation/PlaylistService.cs
βββ Statics/logo-5.png, Style.css
βββ Templates/AddSong.cshtml,BrowsePlaylist.cshtml,CreatePlaylist.cshtml,DeletePlaylist.cshtml,Layout.cshtml,PlaylistOperations.cshtml,ViewPlaylist.cshtml
βββ Server.cs
βββ Swytch-Web-Template.csproj