Skip to content

Conversation

@Tunglies
Copy link
Contributor

Related issues: #14173


Preview

image

IDE & Rust Analyzer

image image image

Test code:

mod me {
    #[tauri::command(alias = "greet_from_me")]
    pub fn hello(name: &str) -> String {
        format!("Hello, {}! Me hello from Rust!", name)
    }
}

mod you {
    #[tauri::command(alias = "greet_from_you")]
    pub fn hello(name: &str) -> String {
        format!("Hi, {}! You hello from Rust!", name)
    }
}

#[tauri::command(alias = "salute")]
fn hello(name: &str) -> String {
    format!("Hello, {}! You've been greeted from Rust!", name)
}

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![hello, me::hello, you::hello])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
import { invoke } from "@tauri-apps/api/core";
import { useState } from "react";
import "./App.css";
import reactLogo from "./assets/react.svg";

function App() {
  const [greetMsg, setGreetMsg] = useState("");
  const [name, setName] = useState("");

  async function handleGreetAll() {
    const [salute, fromMe, fromYou] = await Promise.all([
      invoke<string>("salute", { name }),
      invoke<string>("greet_from_me", { name }),
      invoke<string>("greet_from_you", { name }),
    ]);
    setGreetMsg([salute, fromMe, fromYou].join("\n"));
  }

  return (
    <main className="container">
      <h1>Welcome to Tauri + React</h1>

      <div className="row">
        <a href="https://vite.dev" target="_blank">
          <img src="/vite.svg" className="logo vite" alt="Vite logo" />
        </a>
        <a href="https://tauri.app" target="_blank">
          <img src="/tauri.svg" className="logo tauri" alt="Tauri logo" />
        </a>
        <a href="https://react.dev" target="_blank">
          <img src={reactLogo} className="logo react" alt="React logo" />
        </a>
      </div>
      <p>Click on the Tauri, Vite, and React logos to learn more.</p>

      <form
        className="row"
        onSubmit={(e) => {
          e.preventDefault();
          handleGreetAll();
        }}
      >
        <input
          id="greet-input"
          onChange={(e) => setName(e.currentTarget.value)}
          placeholder="Enter a name..."
        />
        <button type="submit">Greet</button>
      </form>
      <pre>{greetMsg}</pre>
    </main>
  );
}

export default App;

@Tunglies Tunglies requested a review from a team as a code owner November 16, 2025 05:26
@github-project-automation github-project-automation bot moved this to 📬Proposal in Roadmap Nov 16, 2025
@FabianLars FabianLars added this to the 2.10 milestone Nov 16, 2025
@Legend-Master
Copy link
Contributor

Didn't look much into this yet, but I think if the idea is to rename the command, not having both command names valid, we should call it rename similar to #[serde(rename = "name")]

@github-actions
Copy link
Contributor

Package Changes Through 292696f

There are 2 changes which include tauri-macros with minor, @tauri-apps/api with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
@tauri-apps/api 2.9.0 2.9.1
tauri-macros 2.5.1 2.6.0
tauri 2.9.3 2.9.4

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📬Proposal

Development

Successfully merging this pull request may close these issues.

3 participants