#How to use server assets
4 messages · Page 1 of 1 (latest)
There isn’t a detailed section in the provided docs specifically about serverAssets, so I have to infer from the general Nitro storage docs and examples.
From the Nuxt 3/4 server docs, Nitro exposes a storage layer and you access storages with useStorage('<name>'). Custom storages (like Redis) are configured under nitro.storage and then accessed by that name. [Server dir]
However, the knowledge sources you provided:
- Show how to configure
nitro.storage(e.g.redis) and then useuseStorage('redis'). [Server dir] - Do not show any example of
nitro.serverAssetsor of usinguseStorage('assets:<baseName>').
Because of that, I cannot confirm from the docs that:
serverAssetsis the correct key innuxt.configfor Nuxt 3/4, or- that the storage name is indeed
assets:<baseName>(e.g.assets:templates), or - what the correct path/key format for
getItemRaw/getKeysis in this case.
All I can say with confidence from the docs is:
-
For custom storages configured under
nitro.storage, you must use the exact key you configured:export default defineNuxtConfig({ nitro: { storage: { redis: { driver: 'redis', // ... } } } })and then:
const storage = useStorage('redis') const keys = await storage.getKeys() -
The docs do not describe
serverAssetsor theassets:storage namespace, so I cannot verify thatuseStorage('assets:templates')is the correct name or that./templatesis being picked up.
Given this limitation, the most likely reasons for null / [] are:
- The storage name is not actually
assets:templates(but the docs here don’t say what it should be). - The
serverAssetsoption is not correctly configured or not supported as you’re using it. - The path/key you’re passing to
getItemRaw('test.docx') does not match how Nitro indexes those assets.
But I cannot provide the exact correct configuration or usage from the supplied sources.
To move forward, you’d need to check Nitro’s own serverAssets / storage docs (https://nitro.build/config and storage docs) or Nuxt’s latest Nitro config docs beyond what’s included here, because the provided knowledge sources do not contain enough information to answer this precisely.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@nimble storm Kapa.ai is still learning and improving, please let me know how I did by reacting below.