Starter template for Next.js v13 (using new app approach). With TypeScript, tailwindcss and daisyUI.
The Next.js Starter React Tests is a starter template for Next.js, a popular React framework. It includes features such as TypeScript, tailwindcss, and daisyUI. The template provides a home page screenshot and utilizes Next.js v13 with experimental “/app” support. It also includes example server-rendered components populated with data from a jokes API. The template simplifies the setup process by using npm and includes various additional features such as navigation, site layout, Jest, React Testing Library, GitHub action integration for running tests, Prettier configuration, a health check endpoint, and instructions for running tests locally.
To install the Next.js Starter React Tests template, follow these steps:
npx create-next-app nextjs-starter --ts
cd nextjs-starter
npm install tailwindcss daisyui
npx tailwindcss init -p
module.exports = {
purge: [],
darkMode: false,
theme: {
extend: {},
},
variants: {},
plugins: [require('daisyui')],
}
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
@import 'daisyui/dist/full.css';
import React from 'react';
const HomeStyles = () => (
<style jsx global>{`
// Your custom styles here
`}</style>
);
export default HomeStyles;
import React, { useEffect, useState } from 'react';
const Home = () => {
const [joke, setJoke] = useState('');
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
fetch('https://api.jokesapi.com/japi/random')
.then((response) => response.json())
.then((data) => {
setJoke(data.joke);
setIsLoading(false);
});
}, []);
return (
<div>
{isLoading ? (
<p>Loading...</p>
) : (
<p>{joke}</p>
)}
</div>
);
};
export default Home;
import { NextApiRequest, NextApiResponse } from 'next';
export default function handler(_: NextApiRequest, res: NextApiResponse) {
res.status(200).json({ status: 'OK' });
}
npm run dev
npm run test
The Next.js Starter React Tests template is a comprehensive starter template for Next.js web applications. It includes various features such as server components, client components, layouts, and integration with popular libraries like TypeScript, tailwindcss, and daisyUI. The template simplifies the setup process and provides example code for fetching data from APIs, running tests, and configuring additional functionalities like health check endpoints. With its intuitive installation guide and extensive list of features, the Next.js Starter React Tests template is a great option for developers looking to start their Next.js projects efficiently.