Next.js + Tamagui + Solito + Typescript + NewsAPI
Caution
Use yarn
yarn installImportant
Add your NewsAPI key .env.local to apps/next folder:
NEXT_PUBLIC_NEWS_API_KEY=YOUR_NEWS_API_KEY
(or just add it to packages/ui/src/constants/constants.ts):
export const NEWS_API_KEY="YOUR_NEWS_API_KEY"
To start dev:
cd apps/next && yarn run dev- The core functionality is handled by the
useArticleshook, which fetches and manages article data from various categories. It implements features like pagination, deduplication, and debounced loading. - The
getNewsfunction handles API calls with caching for efficiency. - The
useBookmarkArticlemanages bookmarking functionality for news articles. It uses local storage to persist bookmarked articles across sessions. The hook checks if a given article is already saved, and provides a function to toggle its saved status. When the bookmark status changes, it updates both the local state and the storage. - The code is structured to separate data fetching from UI rendering.