Quickstart
The quickest way to wrap your head around how quokka works in practice is probably the examples in the Quokka repository.
And the quickest way to set up a new quokka project is (for now) by copying the quokka-scratch folder from the Quokka repository.
As a single-file entrypoint you can reference the following code, wich is an excempt from the quokka-scratch project:
mod command; mod controller; pub mod entity; pub mod service; use quokka::state::State; use rust_embed::Embed as RustEmbed; #[derive(RustEmbed)] #[folder = "web/templates"] #[include = "*.hbs"] struct Templates; #[derive(RustEmbed)] #[folder = "web/templates"] #[include = "*.scss"] struct Styles; #[derive(RustEmbed)] #[folder = "web/templates"] #[include = "*.js"] struct JavaScript; #[derive(RustEmbed)] #[folder = "web/assets"] struct Resources; pub struct AppBundle {} /// This is provides the minimum to get a Bundle started. /// /// See the [quokka::bundle::Pouch] for available setup functions. impl<S: State + 'static> quokka::bundle::Pouch<S> for AppBundle { /// Find your config module from here fn from_config(_: &quokka::config::Config) -> quokka::Result<Self> where Self: Sized, { Ok(AppBundle {}) } fn configure_styles(&mut self, styles: &mut quokka::state::Styling) -> quokka::Result<()> { styles.register_embedded_styles::<Styles>(); Ok(()) } fn configure_scripts(&mut self, scripts: &mut quokka::state::Scripting) -> quokka::Result<()> { scripts.register_embedded_scripts::<JavaScript>(); Ok(()) } fn configure_templates( &mut self, templates: &mut quokka::state::Templating, ) -> quokka::Result<()> { templates.register_embedded_templates::<Templates>() } fn configure_resources( &mut self, resources: &mut quokka::state::Resources, ) -> quokka::Result<()> { resources.register_embedded_resources::<Resources>(); Ok(()) } fn get_migrations(&self) -> Option<sqlx::migrate::Migrator> { Some(sqlx::migrate!()) } } #[tokio::main] async fn main() -> quokka::Result<()> { Quokka::<DefaultState>::try_default()? .load::<AppBundle>()? .serve() .await }
If you are still missing out some basics, check out the States and Bundles chapters.