Skip to content

Commit 7fe1ddf

Browse files
Add "Intergrate tauri into your existing project" guide (tauri-apps#834)
* Add "Intergrate tauri into your existing project" guide * Move Tauri init fragment * Add Install Tauri CLI command * Fix install tauri CLI command * Simplify Tauri Init fragment * Add install Tauri API command * Refactor fragments * Adjust capitalisation * Refactor integration guide * Rename new project page * Fix broken fragment links * Update docs/guides/getting-started/integrate-tauri.mdx Co-authored-by: Amr Bashir <[email protected]> * Move images to assets folder * Add API and CLI commands, fix tab syncing issue * Rework setup init fragment * Move fragments back * Remove old file * Undo rename * Undo fragment refactor * Undo readme changes * Fix broken links * Add extension to add link break checking * Fix diff and line highlighting * Update docs/guides/getting-started/setup/integrate.mdx Co-authored-by: Amr Bashir <[email protected]> * Update docs/guides/getting-started/setup/integrate.mdx Co-authored-by: Amr Bashir <[email protected]> * Add alternative withGlobalTauri reference * Fix CLI to be a dev dependency * Update docs/guides/getting-started/setup/integrate.mdx Co-authored-by: Amr Bashir <[email protected]> * Add integrate icons * Yay for icons! * Switch to dangerouslySetInnerHTML * Update destDir and devPath text * Add some extra line spacing * Fix typo * Update formatting * Update docs/guides/getting-started/setup/integrate.mdx Co-authored-by: Amr Bashir <[email protected]> * Update init phrasing * Split up Invoke Commands section * Fix heading * Update docs/guides/getting-started/setup/_fragments/_commands.mdx Co-authored-by: Amr Bashir <[email protected]> * Update docs/guides/getting-started/setup/integrate.mdx Co-authored-by: Amr Bashir <[email protected]> * Update HTML guide Co-authored-by: Lorenzo Lewis <[email protected]>
1 parent 480c37c commit 7fe1ddf

File tree

17 files changed

+394
-132
lines changed

17 files changed

+394
-132
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
position: 2

docs/guides/getting-started/setup/_fragments/_commands.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Tauri lets you enhance your Frontend with native capabilities. We call these [Commands][command], essentially Rust functions that you can call from your frontend JavaScript. This enables you to handle heavy processing or calls to the OS in much more performant Rust code.
1+
Tauri lets you enhance your frontend with native capabilities. We call these [Commands][command], essentially Rust functions that you can call from your frontend JavaScript. This enables you to handle heavy processing or calls to the OS in much more performant Rust code.
22

33
Let's make a simple example:
44

5-
```rust
5+
```rust title=src-tauri/src/main.rs
66
#[tauri::command]
77
fn greet(name: &str) -> String {
88
format!("Hello, {}!", name)
@@ -13,7 +13,7 @@ A Command is just like any regular Rust function, with the addition of the `#[ta
1313

1414
Lastly, we also need to tell Tauri about our newly created command so that it can route calls accordingly. This is done with the combination of the `.invoke_handler()` function and the `generate_handler![]` macro you can see below:
1515

16-
```rust
16+
```rust title=src-tauri/src/main.rs
1717
fn main() {
1818
tauri::Builder::default()
1919
// highlight-next-line
@@ -23,6 +23,6 @@ fn main() {
2323
}
2424
```
2525

26-
Now we're ready to call your Command from the JavaScript frontend!
26+
Now you're ready to call your Command from the frontend!
2727

2828
[command]: ../../../features/command.md

docs/guides/getting-started/setup/_fragments/_tauri-init.mdx

Lines changed: 68 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,44 @@
11
import Tabs from '@theme/Tabs'
22
import TabItem from '@theme/TabItem'
3+
import Command, { InstallTauriCli } from '@theme/Command'
34

4-
At the heart of every Tauri app is a Rust binary that manages windows, the webview and calls to the operating system through a Rust crate called `tauri`. This project is managed by [Cargo], the official package manager and general-purpose build tool for Rust.
5+
At the heart of every Tauri app is a Rust binary that manages windows, the webview, and calls to the operating system through a Rust crate called `tauri`. This project is managed by [Cargo], the official package manager and general-purpose build tool for Rust.
56

67
Our Tauri CLI uses Cargo under the hood so you rarely need to interact with it directly. Cargo has many more useful features that are not exposed through our CLI, such as testing, linting, and formatting, so please refer to their [official docs][cargo commands] for more.
78

89
:::info Install Tauri CLI
910

1011
If you haven't installed the Tauri CLI yet you can do so with with one of the below commands. Aren't sure which to use? Check out the [FAQ entry].
1112

12-
<Tabs groupId="package-manager">
13-
<TabItem value="npm" label="npm" default>
14-
15-
```shell
16-
npm install --save-dev @tauri-apps/cli
17-
```
18-
19-
</TabItem>
20-
<TabItem value="yarn" label="Yarn">
21-
22-
```shell
23-
yarn add -D @tauri-apps/cli
24-
```
25-
26-
</TabItem>
27-
<TabItem value="pnpm" label="pnpm">
28-
29-
```shell
30-
pnpm add -D @tauri-apps/cli
31-
```
32-
33-
</TabItem>
34-
<TabItem value="cargo" label="Cargo">
35-
36-
```shell
37-
cargo install tauri-cli
38-
```
39-
40-
</TabItem>
41-
</Tabs>
13+
<InstallTauriCli />
4214

4315
:::
4416

4517
To scaffold a minimal Rust project that is pre-configured to use Tauri, open a terminal and run the following command:
4618

4719
<Tabs groupId="package-manager">
48-
<TabItem value="npm" label="npm" default>
20+
<TabItem value="npm">
4921

5022
```shell
5123
npm tauri init
5224
```
5325

5426
</TabItem>
55-
<TabItem value="yarn" label="Yarn">
27+
<TabItem value="Yarn">
5628

5729
```shell
5830
yarn tauri init
5931
```
6032

6133
</TabItem>
62-
<TabItem value="pnpm" label="pnpm">
34+
<TabItem value="pnpm">
6335

6436
```shell
6537
pnpm tauri init
6638
```
6739

6840
</TabItem>
69-
<TabItem value="cargo" label="Cargo">
41+
<TabItem value="Cargo">
7042

7143
```shell
7244
cargo tauri init
@@ -77,27 +49,63 @@ cargo tauri init
7749

7850
It will walk you through a series of questions:
7951

80-
1. **What is your app name?**
81-
82-
This will be the name of your final bundle and what the OS will call your app. You can use any name you want here.
83-
84-
2. **What should the window title be?**
85-
86-
This will be the title of the default main window. You can use any title you want here.
87-
88-
3. **Where are your web assets (HTML/CSS/JS) located relative to the `<current dir>/src-tauri/tauri.conf.json` file that will be created?**
89-
90-
<div>
91-
This is the path that Tauri will load your frontend assets from when
92-
building for <b>production</b>. Use <code>{props.destDirValue}</code> for
93-
this value.
94-
</div>
95-
96-
4. **What is the URL of your dev server?**
97-
<div>
98-
This can be either a URL or a file path that Tauri will load during{' '}
99-
<b>development</b>. Use <code>{props.devPathValue}</code> for this value.
100-
</div>
52+
<ol>
53+
<li>
54+
<i>What is your app name?</i>
55+
<br />
56+
This will be the name of your final bundle and what the OS will call your
57+
app. You can use any name you want here.
58+
</li>
59+
<br />
60+
<li>
61+
<i>What should the window title be?</i>
62+
<br />
63+
This will be the title of the default main window. You can use any title you
64+
want here.
65+
</li>
66+
<br />
67+
<li>
68+
<i>
69+
Where are your web assets (HTML/CSS/JS) located relative to the{' '}
70+
<code>&lt;current dir&gt;/src-tauri/tauri.conf.json</code> file that will
71+
be created?
72+
</i>
73+
<br />
74+
This is the path that Tauri will load your frontend assets from when
75+
building for <b>production</b>.{' '}
76+
{props.destDirExplination && (
77+
<div dangerouslySetInnerHTML={props.destDirExplination} />
78+
)}
79+
</li>
80+
<br />
81+
<li>
82+
<i>What is the URL of your dev server?</i>
83+
<br />
84+
This can be either a URL or a file path that Tauri will load during{' '}
85+
<b>development</b>.{' '}
86+
{props.devPathExplination && (
87+
<div dangerouslySetInnerHTML={props.devPathExplination} />
88+
)}
89+
</li>
90+
<br />
91+
<li>
92+
<i>What is your frontend dev command?</i>
93+
<br />
94+
This is the command to used to start your frontend dev server.{' '}
95+
{props.beforeDevCommandExplination && (
96+
<div dangerouslySetInnerHTML={props.beforeDevCommandExplination} />
97+
)}
98+
</li>
99+
<br />
100+
<li>
101+
<i>What is your frontend build command?</i>
102+
<br />
103+
This the the command to build your frontend files.{' '}
104+
{props.beforeBuildCommandExplination && (
105+
<div dangerouslySetInnerHTML={props.beforeBuildCommandExplination} />
106+
)}
107+
</li>
108+
</ol>
101109

102110
:::info
103111

@@ -107,16 +115,13 @@ If you're familiar with Rust, you will notice that `tauri init` looks and works
107115

108116
The `tauri init` command generates a folder called `src-tauri`. It's a convention for Tauri apps to place all core-related files into this folder. Let's quickly run through the contents of this folder:
109117

110-
- **`Cargo.toml`**
111-
118+
- **`Cargo.toml`**
112119
Cargo's manifest file. You can declare Rust crates your app depends on, metadata about your app, and much more. For the full reference see [Cargo's Manifest Format][manifest-format].
113120

114-
- **`tauri.conf.json`**
115-
121+
- **`tauri.conf.json`**
116122
This file lets you configure and customize aspects of your Tauri application from the name of your app to the list of allowed APIs. See [Tauri's API Configuration][api config] for the full list of supported options and in-depth explanations for each.
117123

118-
- **`src/main.rs`**
119-
124+
- **`src/main.rs`**
120125
This is the entrypoint to your Rust program and the place where we bootstrap into Tauri. You will find two sections in it:
121126

122127
```rust title=src/main.rs
@@ -136,8 +141,7 @@ The `tauri init` command generates a folder called `src-tauri`. It's a conventio
136141

137142
The `main` function is the entry point and the first function that gets invoked when your program runs.
138143

139-
- **`icons`**
140-
144+
- **`icons`**
141145
Chances are you want a snazzy icon for your app! To get you going quickly, we included a set of default icons. You should switch these out before publishing your application. Learn more about the various icon formats in Tauri's [icons feature guide][icons].
142146

143147
[manifest-format]: https://doc.rust-lang.org/cargo/reference/manifest.html

0 commit comments

Comments
 (0)