After searching a bit, I guess it would be useful. The question is : is it possible to configure Tauri with Astro Js ? The answer is yes. So this post is not a question, but an answer to this question.
To configure Tauri with Astro, we will first create an Astro project. After that we will configure Tauri in order it to “wrap around” the existing Astro project. Pay attention to the order :
-
Install NPM
-
Install Rust
-
Install Tauri :
cargo install tauri --locked -
Install Tauri CLI :
cargo install tauri-cli --locked -
Create Astro project :
npm create astro@latest
Once the Astro project is created, we will use Tauri to integrate into the existing Astro project. To do so, command : cargo tauri init, which creates a minimal Tauri configuration. Check Tauri doc. Tauri will need you to procide a few informations. I give you the base config, please adapt it if you changed the parameters (such as the port or the production files folder name or location) :
- Name of your app
- Name of the window
- Relative path to the production (not dev) files. Per default in Astro the production files are located in the (maybe not currently existing) dist folder. As the path has to be given from the tauri.conf.json file, we will give (per default)
../distin the prompt - The dev server url is per default
http://localhost:4321/ - The frontend dev command in Astro is
npm run dev - The frontend dev command in Astro is
npm run build
When step 6 is done, let’s verify that it is working as expected. Let’s run the command cargo tauri dev. The dev server will be launched on the url specified (here http://localhost:4321) as a typical Astro project. If you type the url in your browser, you will access it, but it is Astro not Tauri. At the same time, Rust will compile the files (which might take some time on first compilation) and generate the application window. If you have the same window as your web browser, then Tauri is working with Astro