877 B
877 B
The server/ folder is ideal for handling server-side logic, such as:
Database operations
Authentication and authorization
File uploads and processing
Integration with third-party APIs
- Accessing Environment Variables You can access environment variables in your server-side code using process.env or Nuxt 3’s runtime config. Example: ts Copy
export default defineEventHandler((event) => { const apiKey = process.env.API_KEY; return { apiKey }; });
- Server-Side Rendering (SSR) Support The server/ folder works seamlessly with Nuxt 3’s SSR capabilities. For example, you can fetch data from your API routes during SSR using useFetch or useAsyncData. Example: vue Copy