usePolyhavenMaterials
Poly Haven material library composable.
Import
typescript
const {
materials,
categories,
isSearching,
searchMaterials,
fetchCategories,
getMaterialInfo,
getMaterialFiles,
} = usePolyhavenMaterials()Return Values
| Property | Type | Description |
|---|---|---|
materials | Ref<PolyhavenMaterial[]> | Search results |
categories | Ref<string[]> | Available categories |
isSearching | Ref<boolean> | Search in progress |
Methods
| Method | Parameters | Returns | Description |
|---|---|---|---|
searchMaterials | query: string, category?: string | Promise<void> | Search textures |
fetchCategories | — | Promise<void> | Load categories |
getMaterialInfo | id: string | Promise<MaterialInfo> | Get asset details |
getMaterialFiles | id: string | Promise<MaterialFiles> | Get file URLs |
API Routes Used
GET /api/polyhaven/search— Search texturesGET /api/polyhaven/categories— Get categoriesGET /api/polyhaven/info/[id]— Asset detailsGET /api/polyhaven/files/[id]— Asset file URLs
Integration Notes
- Proxied through Nuxt server routes (not called directly from client)
- Results cached server-side per type + filter hash
- Debounced search on client side
- Textures are the primary asset type for the materials library
Source
app/composables/usePolyhavenMaterials.ts