Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .scripts/generate-templates-matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const nodeJsTemplates = [
"preact",
"preact-ts",
"angular",
"astro",
];

const matrixConfig = [
Expand Down
1 change: 1 addition & 0 deletions node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Currently supported template presets include:
- `leptos`
- `sycamore`
- `blazor`
- `astro`

You can use `.` for the project name to scaffold in the current directory.

Expand Down
2 changes: 2 additions & 0 deletions src/package_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ impl PackageManager {
Template::Solid,
Template::Angular,
Template::Preact,
Template::Astro,
],
PackageManager::Dotnet => &[Template::Blazor],
}
Expand Down Expand Up @@ -132,6 +133,7 @@ impl PackageManager {
Template::Angular,
Template::Preact,
Template::PreactTs,
Template::Astro,
],
PackageManager::Dotnet => &[Template::Blazor],
}
Expand Down
8 changes: 7 additions & 1 deletion src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub enum Template {
PreactTs,
Blazor,
Dioxus,
Astro,
}

impl Display for Template {
Expand All @@ -83,6 +84,7 @@ impl Display for Template {
Template::PreactTs => write!(f, "preact-ts"),
Template::Blazor => write!(f, "blazor"),
Template::Dioxus => write!(f, "dioxus"),
Template::Astro => write!(f, "astro"),
}
}
}
Expand All @@ -109,6 +111,7 @@ impl FromStr for Template {
"preact-ts" => Ok(Template::PreactTs),
"blazor" => Ok(Template::Blazor),
"dioxus" => Ok(Template::Dioxus),
"astro" => Ok(Template::Astro),
_ => Err(format!(
"{YELLOW}{s}{RESET} is not a valid template. Valid templates are [{}]",
Template::ALL
Expand Down Expand Up @@ -138,6 +141,7 @@ impl Template {
"Blazor - (https://dotnet.microsoft.com/en-us/apps/aspnet/web-apps/blazor/)"
}
Template::Dioxus => "Dioxus - (https://dioxuslabs.com/)",
Template::Astro => "Astro - (https://astro.build/)",
_ => unreachable!(),
}
}
Expand All @@ -163,6 +167,7 @@ impl<'a> Template {
Template::PreactTs,
Template::Blazor,
Template::Dioxus,
Template::Astro,
];

pub fn flavors<'b>(&self, pkg_manager: PackageManager) -> Option<&'b [Flavor]> {
Expand Down Expand Up @@ -227,7 +232,8 @@ impl<'a> Template {
| Template::SolidTs
| Template::Angular
| Template::Preact
| Template::PreactTs => PackageManager::NODE,
| Template::PreactTs
| Template::Astro => PackageManager::NODE,
Template::Yew | Template::Leptos | Template::Sycamore | Template::Dioxus => {
&[PackageManager::Cargo]
}
Expand Down
18 changes: 18 additions & 0 deletions templates/_assets_/astro.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions templates/template-astro/%(pnpm-yarn-npm-bun)%package.json.lte
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "{% package_name %}",
"private": true,
"version": "0.1.0",
"type": "module",
"scripts": {
"build": "astro build",
"dev": "astro dev"
},
"dependencies": {
"@tauri-apps/api": "{% if v2 %}^2{% else %}^1{% endif %}",
"astro": "^5.7.13"
},
"devDependencies": {
"@tauri-apps/cli": "{% if v2 %}^2{% else %}^1{% endif %}"
}
}
12 changes: 12 additions & 0 deletions templates/template-astro/.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2019-2025 Tauri Programme within The Commons Conservancy
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: MIT

beforeDevCommand = {% pkg_manager_run_command %} dev
beforeBuildCommand = {% pkg_manager_run_command %} build
devUrl = http://localhost:1420
frontendDist = ../dist

[files]
astro.svg = public/astro.svg
tauri.svg = public/tauri.svg
7 changes: 7 additions & 0 deletions templates/template-astro/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"astro-build.astro-vscode",
"tauri-apps.tauri-vscode",
"rust-lang.rust-analyzer"
]
}
7 changes: 7 additions & 0 deletions templates/template-astro/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Tauri + Astro

This template should help get you started developing with Tauri and Astro.

## Recommended IDE Setup

[VS Code](https://code.visualstudio.com/) + [Astro](https://marketplace.visualstudio.com/items?itemName=astro-build.astro-vscode) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer).
24 changes: 24 additions & 0 deletions templates/template-astro/_gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# build output
dist/

# generated types
.astro/

# dependencies
node_modules/

# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# environment variables
.env
.env.production

# macOS-specific files
.DS_Store

# jetbrains setting folder
.idea/
34 changes: 34 additions & 0 deletions templates/template-astro/astro.config.ts.lte
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// @ts-check
import { defineConfig } from "astro/config";{% if v2 %}

// @ts-expect-error process is a nodejs global
const host = process.env.TAURI_DEV_HOST;{% endif %}

// https://astro.build/config
export default defineConfig({
server: {{% if v2 %}
port: 1420,{% endif %}
host: host ?? false,
},
vite: {
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent Vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
strictPort: true,{% if v2 %}
hmr: host
? {
protocol: "ws",
host,
port: 1421,
}
: undefined,{% endif %}
watch: {
// 3. tell Vite to ignore watching `src-tauri`
ignored: ["**/src-tauri/**"],
},
},
},
});
55 changes: 55 additions & 0 deletions templates/template-astro/src/components/Welcome.astro.lte
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<script>
import { invoke } from '@tauri-apps/api/{% if v2 %}core{% else %}tauri{% endif %}';

async function greet({
greetInputEl,
greetMsgEl,
}: {
greetInputEl: HTMLInputElement;
greetMsgEl: Element;
}) {
// Learn more about Tauri commands at {% if v2 %}https://tauri.app/develop/calling-rust/{% else %}https://v1.tauri.app/v1/guides/features/command{% endif %}
greetMsgEl.textContent = await invoke('greet', {
name: greetInputEl.value,
});
}

window.addEventListener('DOMContentLoaded', () => {
const greetInputEl: HTMLInputElement =
document.querySelector('#greet-input')!;
const greetMsgEl = document.querySelector('#greet-msg')!;
document
.querySelector('#greet-form')!
.addEventListener('submit', (e) => {
e.preventDefault();
greet({ greetInputEl, greetMsgEl });
});
});
</script>

<main class="container">
<h1>Welcome to Tauri + Astro</h1>

<div class="row">
<a href="https://tauri.app" target="_blank">
<img src="/tauri.svg" class="logo tauri" alt="Tauri Logo" />
</a>
<a href="https://astro.build" target="_blank">
<img src="/astro.svg" class="logo astro" alt="Astro Logo" />
</a>
</div>
<p>Click on the Tauri or Astro logo to learn more.</p>

<form class="row" id="greet-form">
<input id="greet-input" placeholder="Enter a name..." />
<button type="submit">Greet</button>
</form>

<p id="greet-msg"></p>
</main>

<style>
.logo.astro:hover {
filter: drop-shadow(0 0 2em #F041FF);
}
</style>
17 changes: 17 additions & 0 deletions templates/template-astro/src/layouts/Layout.astro.lte
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/astro.svg" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<title>Tauri + Astro App</title>
</head>
<body>
<slot />
</body>
</html>

<style is:global>
{% styles %}
</style>
11 changes: 11 additions & 0 deletions templates/template-astro/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
import Welcome from '../components/Welcome.astro';
import Layout from '../layouts/Layout.astro';
// Welcome to Astro! Wondering what to do next? Check out the Astro documentation at https://docs.astro.build
// Don't want to use any of this? Delete everything in this file, the `assets`, `components`, and `layouts` directories, and start fresh.
---

<Layout>
<Welcome />
</Layout>
5 changes: 5 additions & 0 deletions templates/template-astro/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "astro/tsconfigs/strict",
"include": [".astro/types.d.ts", "**/*"],
"exclude": ["dist"]
}
Loading