Equipment & Items

Hats

Access every hat in Stardew Valley with sorting by name.

Quick Start

import { hats } from 'stardew-valley-data'

// Get all hats
const allHats = hats().get()

// Find a specific hat
const cowboyHat = hats().findByName('Cowboy Hat')

// Get hats sorted alphabetically
const sorted = hats().sortByName().get()

Type Definition

The Hat type represents a single hat item.

FieldTypeDescription
idstringUnique identifier
namestringDisplay name
descriptionstringIn-game description
obtainstringHow to obtain this hat
imagestringRelative path to the hat image

Query Methods

Create a query with the hats() function. Every sort method returns a new HatQuery, so you can chain calls in any order.

Sort Methods

MethodSignatureDescription
sortByNamesortByName(order?: 'asc' | 'desc'): HatQuerySort alphabetically by name. Default: 'asc'.

Terminal Methods

These methods are inherited from the base query and return actual values instead of a new query.

MethodSignatureDescription
getget(): Hat[]Return all results as an array.
firstfirst(): Hat | undefinedReturn the first result, or undefined if empty.
findfind(id: string): Hat | undefinedFind an item by its exact ID.
findByNamefindByName(name: string): Hat | undefinedFind an item by name (case-insensitive exact match).
countcount(): numberReturn the number of results.

Examples

List all hats alphabetically

import { hats } from 'stardew-valley-data'

const allHats = hats().sortByName().get()
allHats.forEach((h) => console.log(`${h.name}: ${h.description}`))

Find how to obtain a specific hat

import { hats } from 'stardew-valley-data'

const hat = hats().findByName('Living Hat')
if (hat) {
  console.log(`${hat.name} — Obtained from: ${hat.obtain}`)
}

Look up a hat by ID

import { hats } from 'stardew-valley-data'

const hat = hats().find('cowboy-hat')
if (hat) {
  console.log(`${hat.name}: ${hat.description}`)
}

Count total hats

import { hats } from 'stardew-valley-data'

console.log(`There are ${hats().count()} hats in the game`)
Previous
Footwear