Difference between static import data and load from app dir
Answered
Mossyrose gall wasp posted this in #help-forum
Mossyrose gall waspOP
Hello everyone
Is there any difference between importing data staticaly like: import data from "../public/data" and putting data inside app dir and load like example here: https://vercel.com/guides/loading-static-file-nextjs-api-route
Is there any difference between importing data staticaly like: import data from "../public/data" and putting data inside app dir and load like example here: https://vercel.com/guides/loading-static-file-nextjs-api-route
Answered by Plague
The difference is anything inside the public folder is publicly viewable meaning your data is not secured and will be visble to the user if they go to
<your-domain>/<data>.json .10 Replies
@Mossyrose gall wasp Hello everyone
Is there any difference between importing data staticaly like: import data from "../public/data" and putting data inside app dir and load like example here: https://vercel.com/guides/loading-static-file-nextjs-api-route
The difference is anything inside the public folder is publicly viewable meaning your data is not secured and will be visble to the user if they go to
<your-domain>/<data>.json .Answer
Mossyrose gall waspOP
thank you for your answer @Plague this approach does not make it server sidedata right? i want to make my data server side is it possible or it is default server side data?
It'll only be accessible in the server
Mossyrose gall waspOP
@"use php" thank you so much ❤️
@"use php" yes, store it anywhere inside `src` folder.
Mark this message as a solution.
Right Click > Apps > Mark Solution
Right Click > Apps > Mark Solution
ty
Mossyrose gall waspOP
@"use php" is there a difference between static import then if i put my data inside src?
@Mossyrose gall wasp <@755810867878297610> is there a difference between static import then if i put my data inside src?
If you put data
inside src, you can import like import json from "@/path/to/file.json"@Mossyrose gall wasp <@755810867878297610> is there a difference between static import then if i put my data inside src?
If your issue is resolved, mark the above message as a sol