1 # xdg-basedir [![Build Status](https://travis-ci.org/sindresorhus/xdg-basedir.svg?branch=master)](https://travis-ci.org/sindresorhus/xdg-basedir)
3 > Get [XDG Base Directory](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) paths
9 $ npm install --save xdg-basedir
16 const xdgBasedir = require('xdg-basedir');
19 //=> '/home/sindresorhus/.local/share'
22 //=> '/home/sindresorhus/.config'
25 //=> ['/home/sindresorhus/.local/share', '/usr/local/share/', '/usr/share/']
31 The properties `.data`, `.config`, `.cache`, `.runtime` will return `null` in the uncommon case that both the XDG environment variable is not set and the users home directory can't be found. You need to handle this case. A common solution is to [fall back to a temp directory](https://github.com/yeoman/configstore/blob/b82690fc401318ad18dcd7d151a0003a4898a314/index.js#L15).
35 Directory for user specific data files.
39 Directory for user specific configuration files.
43 Directory for user specific non-essential data files.
47 Directory for user-specific non-essential runtime files and other file objects (such as sockets, named pipes, etc).
51 Preference-ordered array of base directories to search for data files in addition to `.data`.
55 Preference-ordered array of base directories to search for configuration files in addition to `.config`.
60 MIT © [Sindre Sorhus](https://sindresorhus.com)