title: Installation description: Get started with TresJS. navigation: icon: i-lucide-download seo:
The fastest way to get started with TresJS is using our interactive CLI wizard:
::code-group
npx create-tres my-tres-project
yarn create tres my-tres-project
pnpm create tres my-tres-project
::
The CLI provides an interactive wizard that guides you through:
::prose-list
::prose-note This is the recommended approach for new projects as it handles all the configuration automatically and lets you choose exactly what you need. ::
If you prefer to set up TresJS manually or add it to an existing project, follow the instructions below:
::steps
Install the core TresJS package and the Three.js dependency:
::code-group
npm install @tresjs/core three
yarn add @tresjs/core three
pnpm add @tresjs/core three
::
If you're using TypeScript, install the Three.js type definitions:
::code-group
npm install @types/three -D
yarn add @types/three -D
pnpm add @types/three -D
::
Add the TresJS template compiler options to your vite.config.ts
:
import { templateCompilerOptions } from '@tresjs/core'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [
vue({
// Other config
...templateCompilerOptions
}),
],
})
::prose-warning This configuration is required to make the template compiler work with the TresJS custom renderer and prevent console warnings. :: ::
Install additional TresJS ecosystem packages for extended functionality:
::code-group
npm install @tresjs/cientos @tresjs/post-processing
yarn add @tresjs/cientos @tresjs/post-processing
pnpm add @tresjs/cientos @tresjs/post-processing
::
::prose-note These packages will be automatically imported by the Nuxt module:
If you're using Nuxt, you can use the official TresJS Nuxt module for a seamless integration experience.
::steps
Install the TresJS Nuxt module and Three.js:
::code-group
npm install three @tresjs/nuxt
yarn add three @tresjs/nuxt
pnpm add three @tresjs/nuxt
::
Add @tresjs/nuxt
to the modules
section of your nuxt.config.ts
:
export default defineNuxtConfig({
modules: ['@tresjs/nuxt'],
})
That's it! The module provides several benefits:
::prose-list
TresCanvas
(no need for .client
suffix or <ClientOnly />
)