LIVE NEWS APP with Next.JS 13! Implemented to handle dynamic data and static data alternative to Server Side Rendering and Incremental Static Regeneration. The website is fully responsive and uses Tailwind CSS which further incorporates the feature of dark mode to the app. User can search news with the keywords, categories. Implementation of dynamic page routing and pulling the data from MediaStack News API in efficient and optimized manner has been done to prevernt overloading. Stepzen has been used to launch a GraphQL interface which is queried by FETCH API. Further Typescript is used to reduce the overall number of bugs and errors and the deployed on vercel.
News-App.Demo.mp4
Client
API
GraphQL
- Sign up for a StepZen account HERE
- Log in for a MediaStack API account HERE
- Install Node JS in your computer HERE
To run this project, you will need to add the following environment variables to your .env file
STEPZEN_API_KEY
MEDIASTACK_API_KEY
Install my-project with npm
npx create-next-app news-app
cd news-app
Install dependencies
Install tailwindcss and its peer dependencies via npm, and then run the init command to generate both tailwind.config.js
and postcss.config.js
.
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
Add the paths to all of your template files in your tailwind.config.js
file.
module.exports = {
content: [
"./pages/**/*.{js,ts,jsx,tsx}",
"./components/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
Add the @tailwind
directives for each of Tailwind’s layers to your ./styles/globals.css
file.
@tailwind base;
@tailwind components;
@tailwind utilities;
OR
setup directly with configured installation
npx create-next-app -e with-tailwindcss news-app
Install dependencies
Clone the project
git clone https://github.com/Priyanshu88/News-App.git
Install dependencies
This is a Next.js project bootstrapped with create-next-app
.
npm install
Start the server First, run the development server:
npm run dev
This is a Next.js project bootstrapped with create-next-app
.
Open http://localhost:3000 with your browser to see the result.
Convert Next.js12 to Next.js13 by modifying next.config.js
with
experimental: {
appDir: true,
}
Create an app
folder with page.tsx
and delete index.js
to avoid conficts. Now, create head.tsx
and layout.tsx
and import the globals.css
in layout file.
You can start editing the page by modifying app/page.tsx
. The page auto-updates as you edit the file.
API routes can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in pages/api/hello.js
.
The pages/api
directory is mapped to /api/*
. Files in this directory are treated as API routes instead of React pages.
To learn more about Next.js, take a look at the following resources:
- Next.js13 Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
Signup at Medistack platform, copy the API Access API
key.
- Sign up for a StepZen account HERE
Install the CLI
npm install -g stepzen
After installing the CLI, you can connect it to your account.
Start by logging in using the following command:
stepzen login
You'll see a series of command prompts asking for your StepZen account name and admin key:
What is your account name?: {ACCOUNT}
What is your admin key?: {ADMINKEY}
Your Admin Key and API Key**
When you get your account, log in to StepZen and navigate to the StepZen dashboard, where you will find your account name, and the two keys you need for API authentication:
Initialize a StepZen workspace in the current directory.
stepzen init
Auto-generate your schemas and resolvers using the following StepZen CLI command:
News
stepzen import curl "http://api.mediastack.com/v1/news?access_key=YOUR_ACCESS_KEY&countries=us%2Cgb&limit=100&offset=0&sort=published_desc"
Deploy
stepzen start
To deploy this project run
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.
Your Name - @twitter_handle - 2040020@sliet.ac.in
Project Link: https://github.com/Priyanshu88/News-App.git