#Tauri
> [!warning]
> #2022/03/06 時点の内容であり、[[Tauri]]のv1.0では内容が変わっている。この情報をうのみにせず、あくまで昔の参考情報にとどめること
## 前提条件の確認
https://tauri.studio/docs/getting-started/prerequisites
- [[Rust]]
- [[Node.js]]
- OS specific build tooling
[Setting Up Windows \| Tauri Studio](https://tauri.studio/docs/getting-started/setting-up-windows/) を参考にインストールが必要か確認。
- Visual Studio C++ build tools
- [[Rust]]のインストール時にインストールしたので不要
- 2017と2019が両方入っている場合は2017をアンインストールしなければいけない
- [[Node.js]]
- [[NVM for Windows]]が推奨
- [[Volta]]をインストール済なので不要
- [[rustc]]と[[Cargo]]
- [[rustup]]で[[Rust]]をインストール済なので不要
- [[WebView2]]
- [[Windows 11]]ではプリインストールされているが、[[Windows 10]]なのでインストールが必要
[[WebView2]]を推奨方法でインストールするため、[Evergreen Bootstrapper](https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section)をダウンロード。ダウンロードしたexeを実行すれば20秒くらいで終わる。
## はじめての[[Tauri]]アプリ作成
https://tauri.studio/docs/getting-started/beginning-tutorial
2つの方法がある。
- 新しく[[Tauri]]プロジェクトを作成する
- 既にあるプロジェクトに[[Tauri]]を追加する
今回は前者の方針で。
```console
$ npx create-tauri-app
Ok to proceed? (y) y
? What is your app name? owl-toys
? What should the window title be? NTJ Toys
? What UI recipe would you like to add? create-vite (vanilla, vue, react, svelte, preact, lit) (https://vitejs.dev/guide/#scaffolding-your-first-vite-project)
? Add "@tauri-apps/api" npm package? Yes
? Which vite template would you like to use? svelte-ts
```
動作確認する。
```console
$ cd owl-toys
$ nm run tauri dev
```
`localhost:3000`にアクセスすると[[Svelte]]のトップページが。
![[Pasted image 20220306220426.png]]
その裏で[[crates.io]]のアップデートが走る。コンパイルも。すべてが終わると以下のメッセージが表示される。
```console
Running `target\debug\app.exe`
```
そしてアプリケーションが立ち上がる!