Your First Application
Creating your first application with Wails v3 is an exciting journey into the world of modern desktop app development. This guide will walk you through the process of creating a basic application, showcasing the power and simplicity of Wails.
-
Creating a New Project
Open your terminal and run the following command to create a new Wails project:
This command creates a new directory called
myfirstapp
with all the necessary files. -
Exploring the Project Structure
Navigate to the
myfirstapp
directory. You’ll find several files and folders:Directorybuild/ Contains files used by the build process
- appicon.png The application icon
- config.yml Build configuration
- Taskfile.yml Build tasks
Directorydarwin/ macOS specific build files
- Info.dev.plist Development configuration
- Info.plist Production configuration
- Taskfile.yml macOS build tasks
- icons.icns macOS application icon
Directorylinux/ Linux specific build files
- Taskfile.yml Linux build tasks
Directoryappimage/ AppImage packaging
- build.sh AppImage build script
Directorynfpm/ NFPM packaging
- nfpm.yaml Package configuration
Directoryscripts/ Build scripts
- …
Directorywindows/ Windows specific build files
- Taskfile.yml Windows build tasks
- icon.ico Windows application icon
- info.json Application metadata
- wails.exe.manifest Windows manifest file
Directorynsis/ NSIS installer files
- project.nsi NSIS project file
- wails_tools.nsh NSIS helper scripts
Directoryfrontend/ Frontend application files
- index.html Main HTML file
- main.js Main JavaScript file
- package.json NPM package configuration
Directorypublic/ Static assets
- …
- Inter Font License.txt Font license
- .gitignore Git ignore file
- README.md Project documentation
- Taskfile.yml Project tasks
- go.mod Go module file
- go.sum Go module checksums
- greetservice.go Greeting service
- main.go Main application code
Take a moment to explore these files and familiarize yourself with the structure.
-
Building Your Application
To build your application, execute:
This command compiles a debug version of your application and saves it in a new
bin
directory.Once built, you can run this like you would any normal application:
You’ll see a simple UI, the starting point for your application. As it is the debug version, you’ll also see logs in the console window. This is useful for debugging purposes.
-
Dev Mode
We can also run the application in development mode. This mode allows you to make changes to your frontend code and see the changes reflected in the running application without having to rebuild the entire application.
- Open a new terminal window.
- Run
wails3 dev
. The application will compile and run in debug mode. - Open
frontend/index.html
in your editor of choice. - Edit the code and change
Please enter your name below
toPlease enter your name below!!!
. - Save the file.
This change will reflect in your application immediately.
Any changes to backend code will trigger a rebuild:
- Open
greetservice.go
. - Change the line that has
return "Hello " + name + "!"
toreturn "Hello there " + name + "!"
. - Save the file.
The application will update within a matter of seconds.
-
Packaging Your Application
Once your application is ready for distribution, you can create platform-specific packages:
To create a
.app
bundle:This will create a production build and package it into a
.app
bundle in thebin
directory.To create an NSIS installer:
This will create a production build and package it into an NSIS installer in the
bin
directory.Wails supports multiple package formats for Linux distribution:
For more detailed information about packaging options and configuration, check out our Packaging Guide.
-
Setting up Version Control and Module Name
Your project is created with the placeholder module name
changeme
. It’s recommended to update this to match your repository URL:- Create a new repository on GitHub (or your preferred Git host)
- Initialize git in your project directory:
- Set your remote repository (replace with your repository URL):
- Update your module name in
go.mod
to match your repository URL: - Push your code:
This ensures your Go module name aligns with Go’s module naming conventions and makes it easier to share your code.
Congratulations!
You’ve just created, developed and packaged your first Wails application. This is just the beginning of what you can achieve with Wails v3.
Next Steps
If you are new to Wails, we recommend reading through our Tutorials next which will be a practical guide through the various features of Wails. The first tutorial is Creating a Service.
If you are a more advanced user, check out our Guides for more detailed information on how to use Wails.