Installing TanStack Config and Setting Up a Basic Configuration
Show how to install TanStack Config using npm or yarn, and create a simple configuration file to manage project settings.
npm install @tanstack/config
Install TanStack Config using npm. Alternatively, you can use yarn add @tanstack/config if you prefer yarn over npm.
import { createConfig } from '@tanstack/config';
const appConfig = createConfig({
key: 'myAppConfig',
default: {
apiUrl: 'https://api.example.com',
theme: 'dark'
}
});
console.log(appConfig.apiUrl); // Output will be 'https://api.example.com'
Create a simple configuration file with TanStack Config. This example sets a default API URL and theme for the application. The `createConfig` function initializes the configuration, and you can then use `appConfig` to access your settings throughout your app.