All Projects β†’ vercel-community β†’ rust

vercel-community / rust

Licence: MIT license
πŸ¦€ Rust runtime for β–² Vercel Serverless Functions.

Programming Languages

rust
11053 projects
typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to rust

waifu-generator
Let's pick up your favorite waifu just from the API
Stars: ✭ 31 (-90.86%)
Mutual labels:  vercel
commercejs-chopchop-demo
A Commerce.js starter kit for Next.js. A beautifully designed elegantly developed, end to end commerce experience for developers and agencies. Pre-integrated with Stripe. One-click deploy to Vercel.
Stars: ✭ 129 (-61.95%)
Mutual labels:  vercel
nobelium
A static blog build on top of Notion and NextJS, deployed on Vercel.
Stars: ✭ 1,790 (+428.02%)
Mutual labels:  vercel
frontend-developer-coding-challenge
Are your looking for a remote developer job? Solve this frontend developer challenge and show us what you can do and what you are an expert at!
Stars: ✭ 112 (-66.96%)
Mutual labels:  vercel
waline
πŸ’¬ A Simple, Safe Comment System
Stars: ✭ 1,145 (+237.76%)
Mutual labels:  vercel
StalkStock
A virtual trading website to practice trading stocks using virtual money.
Stars: ✭ 22 (-93.51%)
Mutual labels:  vercel
jahir.dev
My personal website πŸ’Ž – Built using Next.js, TypeScript, MDX, contentlayer, Notion and Stitches styled components
Stars: ✭ 119 (-64.9%)
Mutual labels:  vercel
next-api-og-image
Easy way to generate open-graph images dynamically in HTML or React using Next.js API Routes. Suitable for serverless environment.
Stars: ✭ 179 (-47.2%)
Mutual labels:  vercel
unity-now
β–² Vercel Now plugin for Unity. Deploy WebGL builds with ease
Stars: ✭ 21 (-93.81%)
Mutual labels:  vercel
CodeSignal-Practice Solutions
No description or website provided.
Stars: ✭ 28 (-91.74%)
Mutual labels:  vercel
react-production-deployment
Deploy your React app to production on Netlify, Vercel and Heroku
Stars: ✭ 51 (-84.96%)
Mutual labels:  vercel
contrib-nextjs
Projeto desenvolvido no Contrib de Next.js
Stars: ✭ 11 (-96.76%)
Mutual labels:  vercel
phuctm97.com
🏚 Home on the Web
Stars: ✭ 41 (-87.91%)
Mutual labels:  vercel
octoclairvoyant-webapp
Compare GitHub changelogs across multiple releases in a single view.
Stars: ✭ 45 (-86.73%)
Mutual labels:  vercel
coderplex-org
Official Website for Coderplex Community. Built with Next.js and deployed on Vercel.
Stars: ✭ 32 (-90.56%)
Mutual labels:  vercel
nextjs-cron
Cron jobs with Github Actions for Next.js apps on Vercelβ–²
Stars: ✭ 144 (-57.52%)
Mutual labels:  vercel
dsmtech
πŸš€ The best tech companies and startups in the Greater Des Moines area.
Stars: ✭ 21 (-93.81%)
Mutual labels:  vercel
screenREC
A really simple , ad-free & minimal web based screen recorder πŸ“Ή
Stars: ✭ 67 (-80.24%)
Mutual labels:  vercel
github-jobs-client
Clone of GitHub Jobs website using the design from Frontend Mentor.
Stars: ✭ 22 (-93.51%)
Mutual labels:  vercel
blog-nextjs-tina-tailwind
logana.dev
Stars: ✭ 19 (-94.4%)
Mutual labels:  vercel

Rust

Rust runtime for Vercel Functions.

Community-maintained package to support using Rust inside Vercel Functions as a Runtime.

Usage

First, you'll need a vercel.json file in your project:

{
  "functions": {
    "api/**/*.rs": {
      "runtime": "[email protected]"
    }
  }
}

A Vercel Function will be created for every file that matches api/**/*.rs. Next, you can create a new Function api/user.rs:

use http::{StatusCode};
use vercel_lambda::{lambda, error::VercelError, IntoResponse, Request, Response};
use std::error::Error;

fn handler(_: Request) -> Result<impl IntoResponse, VercelError> {
	let response = Response::builder()
		.status(StatusCode::OK)
		.header("Content-Type", "text/plain")
		.body("Hello World")
		.expect("Internal Server Error");

		Ok(response)
}

// Start the runtime with the handler
fn main() -> Result<(), Box<dyn Error>> {
	Ok(lambda!(handler))
}

Finally, we need an api/Cargo.toml file:

[package]
name = "index"
version = "1.0.0"
authors = ["Your Name <[email protected]>"]
edition = "2018"

[dependencies]
http = "0.1"
vercel_lambda = "*"

[lib]
name = "util"
path = "_util.rs"

Note: Cargo.toml must exist on the same level as the .rs files.

Dependencies

This Builder supports installing dependencies defined in the Cargo.toml file.

Furthermore, more system dependencies can be installed at build time with the presence of a shell build.sh file in the same directory as the entrypoint file.

Local Development

With vercel dev and vercel-rust, you can develop your Rust-based lamdas on your own machine.

During local development with vercel dev, ensure rust and cargo are already installed and available in your PATH, since they will not be installed automatically. The recommended way to install rust and cargo on your machine is with rustup.

Contributing

Since this project contains both Rust and Node.js code, you need to install the relevant dependencies. If you're only working on the JavaScript side, you only need to install those dependencies (and vice-versa).

# install node dependencies
npm install

# install cargo dependencies
cargo fetch

FAQ

Are cargo workspaces supported?

Not quite. Cargo's workspaces feature is a great tool when working on multiple binaries and libraries in a single project. If a cargo workspace is found in the entrypoint, however, vercel-rust will fail to build.

To get around this limitation, create build entries in your vercel.json file for each Cargo.toml that represents a Function within your workspace. In your .vercelignore, you'll want to add any binary or library project folders that aren't needed for your lambdas to speed up the build process like your Cargo.toml workspace.

It's also recommended to have a Cargo.lock alongside your lambda Cargo.toml files to speed up the build process. You can do this by running cargo check or a similar command within each project folder that contains a lambda.

If you have a compelling case for workspaces to be supported by vercel-rust which are too cumbersome with this workaround, please submit an issue! We're always looking for feedback.

Can I use musl/static linking?

Unfortunately, the AWS Lambda Runtime for Rust relies (tangentially) on proc_macro, which won't compile on musl targets. Without musl, all linking must be dynamic. If you have a crate that relies on system libraries like postgres or mysql, you can include those library files with the includeFiles config option and set the proper environment variables, config, etc. that you need to get the library to compile.

For more information, please see this issue.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].