𝗕𝘂𝗶𝗹𝗱𝗶𝗻𝗴 𝗔 𝗡𝗲𝘄𝘀 𝗔𝗽𝗽 𝗪𝗶𝘁𝗵 𝗩𝗮𝗻𝗶𝗹𝗹𝗮 𝗝𝗦
I built NewsScope. It is a real-time news search engine. I used HTML, CSS, and vanilla JS. I avoided React and npm.
The app uses 9 files:
- config.js
- i18n.js
- data.js
- helpers.js
- geo.js
- ui.js
- render.js
- api.js
- main.js
State lives in one flat object in config.js. It is global. I do not use a state library. I call render functions when data changes. This makes the app easy to trace.
I focused on translation. Most apps translate labels. NewsScope translates search keywords. If you pick Japanese, the app sends Japanese words to the API. You get better results.
I added a geo-block check. Some news sites block users from other countries. The app checks the URL before you click. It shows a warning for restricted sites.
I made errors clear. Generic messages are frustrating. The app maps failures to specific messages. You get a clear next step to fix the issue.
I skipped ES modules. This lets you open the app from your hard drive. You do not need a server.
Your API key stays in your browser. It goes straight to the API provider.
Source: https://dev.to/henryxcc/how-i-built-a-multilingual-news-spa-in-vanilla-js-architecture-notes-4e96