You will be working on migrating a Next.js application from the pages
directory to the new app
router.
NextAuth.js
to handle authentication in a Next.js
app.
i18next
to handle internationalization.
NProgress
to show a progress bar at the top when a page changes.
redux
for state management.
reduxjs/toolkit
for API caching and data fetching.
the application uses a fake API for login and registration: DummyJSON Auth API.
Your main task is to migrate the application from the pages
dir to the new app
router. While doing so, you are required to:
Implement authentication and localization without using any third-party libraries. Enable i18n routing. Improve the current code to follow best practices.
Follow these steps to set up the project locally:
git clone https://github.com/msaaqcom/assignment-frontend-blueprint/
cd assignment-frontend-blueprint
npm install
cp .env.example .env
npm run dev
contextes/
AppContext.tsx
AuthContext.tsx
ToastContext.tsx
hooks/
- Custom hooks used in the application.store/
- Redux store setup.types/
- TypeScript types.utils/
- Utility helpers.pages/
- Contains app pages.public/
- Contains public eg: (locales).styles/
- Contains global styles.next-i18next.config.js
- i18next config
- Move the application from the
pages
directory to the newapp
router in Next.js.
- remove
NextAuth.js
and implement a Cookie-based session management
- remove
i18next
and implement a solution using Next.js built-in support for internationalized
- Implement i18n routing to support multiple languages.
- while migrating the app if you see any features that could be implemented better or improved by following best practices just apply what you think is right
- Remove Redux and Reduxjs Toolkit from the application and use built-in solutions
- Use Tailwind CSS to design this page (with dark and light mode supported) and apply a better design to the entire application UIs.
- Ensure the application works perfectly with SEO.
- Implement appropriate metadata for all pages to enhance SEO.
- in the comments page you should apply pagination to the comments to replace Reduxjs Toolkit with whatever you feel right
- deploy your project to Vercel
Once you have completed the task, submit your changes by pushing to a new branch and creating a pull request in your cloned repository. Include a detailed description of the changes you made and any additional improvements or features you implemented.
- if user not login will redirect to home page and register and login page will be hidden.
- I updated the project (nextjs 14) to use the new Next.js router. and update all the dependencies.
- I have created a new folder called
app
and moved all the pages to it. - I have removed
NextAuth.js
and implemented a Cookie-based session management. and context API for authentication. in thecontextes
folder. AuthContext.tsx - I use server action to handle the login and register. in the server action folder.
- if user authenticated the user will be redirected to the home page.
- i make every page server component. for SEO and performance.
- I make hook for every page to split the logic and the view.
- I have removed
i18next
and implemented a solution using Next.js built-in support for internationalized. - I have implemented i18n routing to support multiple languages.
- I have created a new folder called
dictionaries
and added the translation files. - I have created a new button to change the language. in home page
- I updated ar.json and en.json files.
- I make file for the SEO keywords and description. called
seo-keywords.util.ts
in the utils folder. - every page server component for SEO and performance.
- in comments page i fetch (async/await) data with fetch api and i use the built-in nextjs 14 cache.
- i revalidate the data when add new comment only
- i make pagination for the comments. with react-paginate library. and make shared component for the pagination. in components folder.
- when add new comment will appear in the top of the comments list.
- I design the page with Tailwind CSS and make it responsive. only with tailwind css.
- I make dark light and switch button
- I use swiper for the slider in the page.
- I Make hamburger menu for the mobile view.
- I make the page responsive for all devices.