Nextron ( Next.Js + Electron ) project boilerplate in TypeScript, with TailwindCSS + Shadcn/ui, web and desktop crossbuild
This repository is a Nextron ( Next.Js + Electron ) project template in TypeScript with a Next.Js 14 App Router that includes TailwindCSS and the Shadcn/ui component library. This project is also configured so that the application can be built for both web and desktop versions with the same code.
The aim of this project is to enable anyone to quickly and easily start up a project using these technologies.
How to create a new application with this template ?
There are two ways to create a new project with this template. This project uses and runs under Node 20, so it's advisable to use NVM to manage and use the correct version of Node.
To create a new project, use the command below :
# with npx
$ npx install-nextron-shadcn-boilerplate
# with yarn
$ SOON
# with pnpm
$ SOON
On GitHub, select this repository as a template.
To create a new project, just copy it by running :
git clone git@github.com:MaximePremont/boilerplate-nextron-shadcn.git
Then, install depedencies by running npm install in the project folder.
You can use npm run next:dev to start a next web application in development mode with hot reload.
You can use npm run electron:dev to start an electron desktop application in development mode with hot reload.
You can build your next web application by using npm run next:build. Then you can start it in production mode with npm run next:start.
You can build your Electron desktop application on different systems by using the commands bellow :
npm run electron:build-current Build for current system
npm run electron:build-all Build on all systems
npm run electron:build-win32 Build on Windows x32
npm run electron:build-win64 Build on Windows x64
npm run electron:build-linux Build for linux*
npm run electron:build-mac Build for MacOs**
npm run electron:build-mac-universal Universal build for MacOs**
*For linux, you can change the package type ( snap, deb... ) by editing the electron-builder.yml file. You may need to install some packages ( for exemple rmp to build a rpm).
**MacOs versions can only be build using a Mac.
To deploy your web application to Vercel, follow these steps:
- Create a
vercel.jsonfile in your project root with the following configuration:
{
"buildCommand": "yarn next:build",
"outputDirectory": "renderer/.next",
"framework": "nextjs",
"installCommand": "yarn install"
}-
Push your code to your Git repository
-
Connect your repository to Vercel:
- Go to Vercel Dashboard
- Click "New Project"
- Import your repository
- Vercel will automatically detect the Next.js configuration
- Click "Deploy"
Important Notes:
- The web version will be built using the
next:buildcommand - Make sure any Electron-specific code is wrapped in environment checks
- Environment variables can be configured in the Vercel dashboard
- The web version will be served from the
renderer/.nextdirectory
When developing for both web and desktop platforms, keep these important considerations in mind:
- Environment-Specific Code:
// Example of environment-specific code wrapping
if (process.env.BUILD_TARGET === 'desktop') {
// Electron-specific code here
} else {
// Web-specific code here
}- Native Dependencies:
- Any native dependencies or Electron-specific features need to be:
- Made conditional based on the platform
- Provided with web alternatives
- Or completely excluded from the web build
- Environment Variables:
- Maintain separate environment configurations for:
- Web deployment (Vercel dashboard)
- Desktop development
- Production builds
- Ensure all necessary variables are properly set in each environment
- Build Process:
- The web build process is handled by Vercel
- Desktop builds use electron-builder
- Make sure your code can handle both build processes
To build and distribute your desktop application, you have several options:
- Build for current platform:
yarn electron:build-currentThis will create a distributable for your current operating system.
- Build for specific platforms:
# Windows (32-bit)
yarn electron:build-win32
# Windows (64-bit)
yarn electron:build-win64
# Linux
yarn electron:build-linux
# macOS
yarn electron:build-mac
# macOS Universal (Intel + Apple Silicon)
yarn electron:build-mac-universal- Build for all platforms:
yarn electron:build-allImportant Notes:
- The built applications will be available in the
distdirectory - For macOS builds, you must build on a macOS system
- For Windows builds, you can build on any platform
- For Linux builds, you can customize the package type (deb, rpm, snap, etc.) in
electron-builder.yml - Make sure to test the built application before distribution
- Consider code signing for production releases
Distribution Options:
- Windows:
.exeinstaller or portable executable - macOS:
.dmgor.pkginstaller - Linux:
.deb,.rpm,.AppImage, or.snap(configurable)
For more advanced distribution options, refer to the electron-builder documentation.
For full usage, please read the Nextron documentation.
To install Shadcn/ui components, just use npx shadcn@latest add MY-COMPONENT as explained in the official documentation.
Eslint and Prettier are installed and configured to work with the project. Feel free to edit configuration files according to your preferences.
Please note that contributors to this project must adhere to the defined standard.
Feel free to improve this project by developing ( contribution guide ) or participating in community discussions.
This project in under the MIT License.

