Skip to content
Tauri 中文网

前端配置

Tauri 与前端无关,开箱即用,支持大多数前端框架。但是,有时框架需要一些额外的配置才能与 Tauri 集成。以下是具有推荐配置的框架列表。

¥Tauri is frontend agnostic and supports most frontend frameworks out of the box. However, sometimes a framework need a bit of extra configuration to integrate with Tauri. Below is a list of frameworks with recommended configurations.

如果未列出框架,则它可能与 Tauri 一起使用而无需额外配置,或者可能尚未记录。欢迎为添加可能需要额外配置的框架做出任何贡献,以帮助 Tauri 社区中的其他人。

¥If a framework is not listed then it may work with Tauri with no additional configuration needed or it could have not been documented yet. Any contributions to add a framework that may require additional configuration are welcome to help others in the Tauri community.

配置清单

¥Configuration Checklist

从概念上讲,Tauri 充当静态 Web 主机。你需要为 Tauri 提供一个文件夹,其中包含一些 HTML、CSS、Javascript 和可能的 WASM 的混合,可以提供给 Tauri 提供的 webview。

¥Conceptually Tauri acts as a static web host. You need to provide Tauri with a folder containing some mix of HTML, CSS, Javascript and possibly WASM that can be served to the webview Tauri provides.

以下是将前端与 Tauri 集成所需的常见场景清单:

¥Below is a checklist of common scenarios needed to integrate a frontend with Tauri:

  • 使用静态站点生成 (SSG)、单页应用 (SPA) 或经典多页应用 (MPA)。Tauri 本身不支持基于服务器的替代方案(例如 SSR)。

    ¥Use static site generation (SSG), single-page applications (SPA), or classic multi-page apps (MPA). Tauri does not natively support server based alternatives (such as SSR).

  • 对于移动开发,需要某种可以在内部 IP 上托管前端的开发服务器。

    ¥For mobile development, a development server of some kind is necessary that can host the frontend on your internal IP.

  • 在你的应用和 API 之间使用适当的客户端-服务器关系(不使用带有 SSR 的混合解决方案)。

    ¥Use a proper client-server relationship between your app and your API’s (no hybrid solutions with SSR).

JavaScript

对于大多数项目,我们建议 SPA 框架(例如 React、Vue、Svelte 和 Solid)使用 Vite,但也建议使用纯 JavaScript 或 TypeScript 项目。此处列出的大多数其他指南展示了如何使用元框架,因为它们通常是为 SSR 设计的,因此需要特殊配置。

¥For most projects we recommend Vite for SPA frameworks such as React, Vue, Svelte, and Solid, but also for plain JavaScript or TypeScript projects. Most other guides listed here show how to use Meta-Frameworks as they are typically designed for SSR and therefore require special configuration.

Rust



Tauri 中文网 - 粤ICP备13048890号