• Stars
    star
    164
  • Rank 230,032 (Top 5 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created almost 5 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Set up a modern Yew web app by running one command.

Create Yew App

Create Yew apps with no build configuration.

  • Creating an App โ€“ How to create a new app.
  • Yew - Rust / Wasm framework for building client web apps.
  • Awesome Yew - A curated list of awesome things related to Yew / WebAssembly.

Check out a live demo powered by Create Yew App.

Quick Overview

npx create-yew-app my-app
cd my-app
trunk serve

(npx comes with npm 5.2+ and higher, see instructions for older npm versions)

Then open http://localhost:8080/ to see your app.
When youโ€™re ready to deploy to production, create a minified bundle with trunk build.

Getting Started

Install Rust wasm target

rustup target add wasm32-unknown-unknown

Install Trunk.

Creating an App

Youโ€™ll need to have Node 8.16.0 or Node 10.16.0 or later version on your local development machine (but itโ€™s not required on the server). You can use nvm (macOS/Linux) or nvm-windows to switch Node versions between different projects.

To create a new app, you may choose one of the following methods:

npx

npx create-yew-app my-app

(npx is a package runner tool that comes with npm 5.2+ and higher, see instructions for older npm versions)

npm

npm init yew-app my-app

npm init <initializer> is available in npm 6+

Yarn

yarn create yew-app my-app

yarn create <starter-kit-package> is available in Yarn 0.25+

Project structure

It will create a directory called my-app inside the current folder.
Inside that directory, it will generate the initial project structure and install the transitive dependencies:

my-app
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ Cargo.toml
โ”œโ”€โ”€ index.html
โ”œโ”€โ”€ LICENSE-APACHE
โ”œโ”€โ”€ LICENSE-MIT
โ”œโ”€โ”€ tailwind.config.js
โ”œโ”€โ”€ tailwind.css
โ”œโ”€โ”€ Trunk.toml
โ”œโ”€โ”€ public
โ”‚   โ”œโ”€โ”€ favicon.ico
โ”‚   โ”œโ”€โ”€ logo.svg
โ””โ”€โ”€ src
    โ”œโ”€โ”€ lib.rs
    โ”œโ”€โ”€ main.rs
    โ”œโ”€โ”€ app
    โ”‚   โ”œโ”€โ”€ about.rs
    โ”‚   โ”œโ”€โ”€ home.rs
    โ”‚   โ””โ”€โ”€ mod.rs
    โ””โ”€โ”€ components
        โ”œโ”€โ”€ nav.rs
        โ””โ”€โ”€ mod.rs

No configuration or complicated folder structures, only the files you need to build your app.
Once the installation is done, you can open your project folder:

cd my-app

Inside the newly created project, you can run some built-in commands:

trunk serve

Runs the app in development mode.
Open http://localhost:8080 to view it in the browser.

The page will automatically reload if you make changes to the code.
You will see the build errors and lint warnings in the console.

trunk build

Builds the app for production to the dist folder.
It correctly bundles Yew in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.

Your app is ready to be deployed.

wasm-pack test --headless --chrome

Runs the test watcher in an interactive mode.
By default, runs tests related to files changed since the last commit.

Contributing

Feel free to take a look at the current issues in this repo for anything that currently needs to be worked on.

You are also welcome to open a PR or a new issue if you see something is missing or could be improved upon.

License

Apache License (Version 2.0)

See LICENSE for details.