Skip to content

A simple and minimal template for development of web applications using Next.js as a frontend and Rocket as a backend with Diesel as an ORM.

License

Notifications You must be signed in to change notification settings

ninjomcs/next-rocket-diesel-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Next.js + Rocket + Diesel starter

A simple and minimal template for development of web applications using Next.js as a frontend and Rocket as a backend with Diesel as an ORM.

Setup

  1. Ensure you have the latest stable versions of rustup and Node.js installed
  2. Clone the repository, run npm i
  3. Follow the Diesel getting started guide for configuring and setting up Diesel

Usage

Notes

For development, use npm run dev. This starts both the Next.js development server as well as the Rocket server. There is a proxy in place for all requests to localhost:3000/api, which goes to localhost:8000/api. Therefore, you can simply fetch data using fetch("/api").

Rust database example

To use the database connection, simply pass the DbConn type as a request guard to a handler. The following example uses the fictional Logs type and is adapted from the Rocket documentation.

#[get("/logs/<id>")]
fn get_logs(conn: DbConn, id: usize) -> Logs {
    logs::filter(id.eq(log_id)).load(&*conn)
}

About

A simple and minimal template for development of web applications using Next.js as a frontend and Rocket as a backend with Diesel as an ORM.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published