Skip to content

usePolyhavenMaterials

Poly Haven material library composable.

Import

typescript
const {
  materials,
  categories,
  isSearching,
  searchMaterials,
  fetchCategories,
  getMaterialInfo,
  getMaterialFiles,
} = usePolyhavenMaterials()

Return Values

PropertyTypeDescription
materialsRef<PolyhavenMaterial[]>Search results
categoriesRef<string[]>Available categories
isSearchingRef<boolean>Search in progress

Methods

MethodParametersReturnsDescription
searchMaterialsquery: string, category?: stringPromise<void>Search textures
fetchCategoriesPromise<void>Load categories
getMaterialInfoid: stringPromise<MaterialInfo>Get asset details
getMaterialFilesid: stringPromise<MaterialFiles>Get file URLs

API Routes Used

  • GET /api/polyhaven/search — Search textures
  • GET /api/polyhaven/categories — Get categories
  • GET /api/polyhaven/info/[id] — Asset details
  • GET /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

Built with VitePress