{"id":13597325,"url":"https://github.com/gaucho-labs/leptos-query","last_synced_at":"2026-03-07T12:01:19.347Z","repository":{"id":181019829,"uuid":"666083082","full_name":"gaucho-labs/leptos-query","owner":"gaucho-labs","description":"Async state management for Leptos, providing simplified data fetching, integrated reactivity, SSR support, and smart cache management.","archived":false,"fork":false,"pushed_at":"2024-04-14T19:07:18.000Z","size":371,"stargazers_count":179,"open_issues_count":8,"forks_count":18,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-14T11:48:37.672Z","etag":null,"topics":["async","cache","data-fetching","leptos","reactive","rust","stale-while-revalidate","state-management"],"latest_commit_sha":null,"homepage":"https://leptos-query-demo.vercel.app/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gaucho-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-13T17:08:18.000Z","updated_at":"2025-12-07T16:30:47.000Z","dependencies_parsed_at":"2024-02-07T21:26:21.082Z","dependency_job_id":"567898b0-190a-44f0-a14f-895ec6d9a171","html_url":"https://github.com/gaucho-labs/leptos-query","commit_stats":null,"previous_names":["nicoburniske/leptos_query","gaucho-labs/leptos-query"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/gaucho-labs/leptos-query","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaucho-labs%2Fleptos-query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaucho-labs%2Fleptos-query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaucho-labs%2Fleptos-query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaucho-labs%2Fleptos-query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gaucho-labs","download_url":"https://codeload.github.com/gaucho-labs/leptos-query/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaucho-labs%2Fleptos-query/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30212485,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T09:02:10.694Z","status":"ssl_error","status_checked_at":"2026-03-07T09:02:08.429Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","cache","data-fetching","leptos","reactive","rust","stale-while-revalidate","state-management"],"created_at":"2024-08-01T17:00:30.669Z","updated_at":"2026-03-07T12:01:18.872Z","avatar_url":"https://github.com/gaucho-labs.png","language":"Rust","funding_links":[],"categories":["Libraries","Rust"],"sub_categories":["Unofficial"],"readme":"\u003c!-- cargo-rdme start --\u003e\n\n# Leptos Query\n\n\u003cp align=\"center\"\u003e\n   \u003ca href=\"https://github.com/gaucho-labs/leptos-query\"\u003e\n      \u003cimg src=\"https://raw.githubusercontent.com/gaucho-labs/leptos-query/main/logo.svg\" alt=\"Leptos Query\" width=\"150\"/\u003e\n   \u003c/a\u003e\n\u003c/p\u003e\n\n[\u003cimg alt=\"github\" src=\"https://img.shields.io/badge/github-gaucho--labs/leptos--query-8da0cb?style=for-the-badge\u0026labelColor=555555\u0026logo=github\" height=\"20\"\u003e](https://github.com/gaucho-labs/leptos-query)\n[\u003cimg alt=\"crates.io\" src=\"https://img.shields.io/crates/v/leptos_query.svg?style=for-the-badge\u0026color=fc8d62\u0026logo=rust\" height=\"20\"\u003e](https://crates.io/crates/leptos_query)\n[\u003cimg alt=\"docs.rs\" src=\"https://img.shields.io/badge/docs.rs-leptos_query-66c2a5?style=for-the-badge\u0026labelColor=555555\u0026logo=docs.rs\" height=\"20\"\u003e](https://docs.rs/leptos_query)\n[\u003cimg alt=\"build status\" src=\"https://img.shields.io/github/actions/workflow/status/gaucho-labs/leptos_query/rust.yml?branch=main\u0026style=for-the-badge\" height=\"20\"\u003e](https://github.com/gaucho-labs/leptos_query/actions?query=branch%3Amain)\n\n\n[FAQ](https://github.com/gaucho-labs/leptos-query/blob/main/FAQ.md) | [Examples](https://github.com/gaucho-labs/leptos-query/tree/main/example/) | [Live Demo](https://leptos-query-demo.vercel.app/)\n\n## About\n\nLeptos Query is a async state management library for [Leptos](https://github.com/leptos-rs/leptos).\n\nHeavily inspired by [Tanstack Query](https://tanstack.com/query/latest/).\n\nQueries are useful for data fetching, caching, and synchronization with server state.\n\nA Query provides:\n- Caching\n- Request de-duplication\n- Invalidation\n- Background refetching\n- Refetch intervals\n- Memory management with cache lifetimes\n- Cancellation\n- Debugging tools\n- Optimistic updates\n- Client side cache persistance (localstorage, indexdb, custom, etc.)\n\n\n## The main entry points to using Queries are:\n- [`create_query`](create_query::create_query) - **Recommended**: Creates a [`QueryScope`] which encapsulates `use_query` and other methods for managing queries.\n- [`use_query`][use_query::use_query] - A query primitive for reading, caching, and refetching data.\n\n## Feature Flags\n- `csr` Client-side rendering: Use queries on the client.\n- `ssr` Server-side rendering: Initiate queries on the server.\n- `hydrate` Hydration: Ensure that queries are hydrated on the client, when using server-side rendering.\n- `local_storage` - Enables local storage persistance for queries.\n- `index_db` - Enables index db persistance for queries.\n\n## Version compatibility for Leptos and Leptos Query\n\nThe table below shows the compatible versions of `leptos_query` for each `leptos` version. Ensure you are using compatible versions to avoid potential issues.\n\n| `leptos` version | `leptos_query` version |\n|------------------|------------------------|\n| 0.6.*            | 0.5.* or 0.4.*         |\n| 0.5.*            | 0.3.*                  |\n\n\n## Installation\n\n```bash\ncargo add leptos_query\n```\n\nThen add the relevant feature(s) to your `Cargo.toml`\n\n```toml\n\n[features]\nhydrate = [\n    \"leptos_query/hydrate\",\n    # ...\n]\nssr = [\n    \"leptos_query/ssr\",\n    # ...\n ]\n\n```\n\n\n## Quick Start\n\n\u003e If you are using SSR you may have to use [`supress_query_load`](https://docs.rs/leptos_query/latest/leptos_query/fn.suppress_query_load.html) in your server's main function. See the [FAQ](https://github.com/gaucho-labs/leptos_query/blob/main/FAQ.md#why-am-i-getting-a-panic-on-my-leptos-main-function) for more information.\n\nIn the root of your App, provide a query client with [provide_query_client] or [provide_query_client_with_options] if you want to override the default options.\n\n```rust\nuse leptos_query::*;\nuse leptos::*;\n\n#[component]\npub fn App() -\u003e impl IntoView {\n    // Provides Query Client for entire app.\n    provide_query_client();\n\n    // Rest of App...\n}\n```\n\nThen make a query function with [`create_query`][crate::create_query::create_query()]\n\n```rust\nuse leptos::*;\nuse leptos_query::*;\n\n\n// Query for a track.\nfn track_query() -\u003e QueryScope\u003cTrackId, TrackData\u003e {\n    create_query(\n        get_track,\n        QueryOptions::default(),\n    )\n}\n\n// Make a key type.\n#[derive(Debug, Clone, Hash, Eq, PartialEq)]\nstruct TrackId(i32);\n\n// The result of the query fetcher.\n#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]\nstruct TrackData {\n   name: String,\n}\n\n// Query fetcher.\nasync fn get_track(id: TrackId) -\u003e TrackData {\n    todo!()\n}\n\n```\n\nNow you can use the query in any component in your app.\n\n```rust\nuse leptos::*;\nuse leptos_query::*;\n\n#[component]\nfn TrackView(id: TrackId) -\u003e impl IntoView {\n    let QueryResult {\n        data,\n        ..\n    } = track_query().use_query(move|| id.clone());\n\n    view! {\n       \u003cdiv\u003e\n           // Query data should be read inside a Transition/Suspense component.\n           \u003cTransition\n               fallback=move || {\n                   view! { \u003ch2\u003e\"Loading...\"\u003c/h2\u003e }\n               }\u003e\n               {move || {\n                    data\n                        .get()\n                        .map(|track| {\n                           view! { \u003ch2\u003e{track.name}\u003c/h2\u003e }\n                        })\n               }}\n           \u003c/Transition\u003e\n       \u003c/div\u003e\n    }\n}\n```\nFor a complete working example see [the example directory](/example)\n\n## Devtools Quickstart\n\nTo use the devtools, you need to add the devtools crate:\n\n```bash\ncargo add leptos_query_devtools\n```\n\nThen in your `cargo.toml` enable the `csr` feature.\n\n#### Hydrate Example\n- If your app is using SSR, then this should go under the \"hydrate\" feature.\n```toml\n[features]\nhydrate = [\n    \"leptos_query_devtools/csr\",\n]\n```\n\n#### CSR Example\n- If your app is using CSR, then this should go under the \"csr\" feature.\n```toml\n[features]\ncsr = [\n    \"leptos_query_devtools/csr\",\n]\n```\n\nThen in your app, render the devtools component. Make sure you also provide the query client.\n\nDevtools will by default only show in development mode. It will not be shown, or included in binary, when you build your app in release mode. If you want to override this behaviour, you can enable the `force` feature.\n\n```rust\n\nuse leptos_query_devtools::LeptosQueryDevtools;\nuse leptos_query::*;\nuse leptos::*;\n\n#[component]\nfn App() -\u003e impl IntoView {\n    provide_query_client();\n\n    view!{\n        \u003cLeptosQueryDevtools /\u003e\n        // Rest of App...\n    }\n}\n\n```\n\n\u003c!-- cargo-rdme end --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaucho-labs%2Fleptos-query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaucho-labs%2Fleptos-query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaucho-labs%2Fleptos-query/lists"}