Nuxt 3 with Three.js
Nuxt 3 with Three.js
In this article, we will learn how to use Three.js with Nuxt 3 and build cool things!
What is Three.js?
Three.js is a cross-browser JavaScript library and application programming interface (API) used to create and display animated 3D computer graphics in a web browser. Three.js uses WebGL.
What is Nuxt 3?
Nuxt 3 is a web application framework based on Vue.js, it is designed to make web development powerful and performant.
Getting Started
First, we need to create a new Nuxt 3 project:
terminalterminal
Then, we need to install the Three.js dependency:
terminalterminal
Using Three.js
Now, we can use Three.js in our Nuxt 3 project. Let's create a new component called arch.vue
in the components
directory and add the following code:
arch.vuearch.vue
- don't forget when using
arch.vue
component you need to wrap it withClientOnly
component to prevent errors on server-side rendering; or add.client
to end of component name.