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

github-actions bot commented Nov 19, 2025

Package Changes Through 5d44307

There are 3 changes which include tauri-macros with minor, tauri-macos-sign with patch, tauri-bundler 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-macos-sign 2.3.1 2.3.2
tauri-bundler 2.7.4 2.7.5
tauri-macros 2.5.2 2.6.0
tauri 2.9.4 2.9.5
@tauri-apps/cli 2.9.5 2.9.6
tauri-cli 2.9.5 2.9.6

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


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

@Tunglies
Copy link
Contributor Author

Tunglies commented Nov 26, 2025

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")]

I initially thought of using rename with #[serde(rename = "name")], but ended up keeping alias for functionality first and reference the issue. See if any review ideals I can go further.

@Tunglies Tunglies changed the title feat(macros): add support for alias command macro in tauri-macros #14173 feat(macros): add support for rename command macro in tauri-macros #14173 Dec 1, 2025
@Tunglies
Copy link
Contributor Author

Tunglies commented Dec 1, 2025

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")]

It should be clearer now, changed to #[tauri::command(rename = "name")] . Since the new serde method exposed to user, might conflect with #serde(rename_all = "snake_case"), but the priority of rename_all is higher. We might need document on this behavior.

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