Skip to content

Commit f71e514

Browse files
docs: nextjs class app (#251)
1 parent d4750cb commit f71e514

22 files changed

+672
-13
lines changed

demo/next-classic-app/.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
.yarn/install-state.gz
8+
9+
# testing
10+
/coverage
11+
12+
# next.js
13+
/.next/
14+
/out/
15+
16+
# production
17+
/build
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
next-env.d.ts

demo/next-classic-app/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18+
19+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20+
21+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22+
23+
## Learn More
24+
25+
To learn more about Next.js, take a look at the following resources:
26+
27+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29+
30+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31+
32+
## Deploy on Vercel
33+
34+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35+
36+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

demo/next-classic-app/i18n.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": 1.2,
3+
"locale": {
4+
"source": "en",
5+
"targets": [
6+
"es"
7+
]
8+
},
9+
"buckets": {
10+
"json": {
11+
"include": [
12+
"src/locales/[locale].json"
13+
]
14+
}
15+
}
16+
}

demo/next-classic-app/i18n.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 1
2+
checksums:
3+
63f4c97e43b1d06779a7f553869f769a:
4+
home.title: aa72464a366b091aa6f2037ca869c09c
5+
counter.title: 8a1e7a9e646c72c2259e67556795eca4
6+
counter.decrement: ccc26acd514d8f23f4874a17f57c26c9
7+
counter.increment: 2286b28fa37112af76d6f5952c4b928e
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** @type {import('next').NextConfig} */
2+
const nextConfig = {};
3+
4+
export default nextConfig;

demo/next-classic-app/package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "next-classic-app",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"start": "next start",
9+
"i18n": "npx replexica@latest i18n"
10+
},
11+
"dependencies": {
12+
"@formatjs/intl": "^2.10.8",
13+
"@formatjs/intl-localematcher": "^0.5.5",
14+
"negotiator": "^0.6.3",
15+
"next": "14.2.15",
16+
"react": "^18",
17+
"react-dom": "^18",
18+
"react-intl": "^6.8.0"
19+
},
20+
"devDependencies": {
21+
"@types/negotiator": "^0.6.3",
22+
"@types/node": "^20",
23+
"@types/react": "^18",
24+
"@types/react-dom": "^18",
25+
"postcss": "^8",
26+
"tailwindcss": "^3.4.1",
27+
"typescript": "^5"
28+
}
29+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('postcss-load-config').Config} */
2+
const config = {
3+
plugins: {
4+
tailwindcss: {},
5+
},
6+
};
7+
8+
export default config;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use client';
2+
3+
import { useState } from 'react';
4+
import { useIntl, FormattedMessage } from 'react-intl';
5+
6+
// Example of a client component
7+
export default function Counter() {
8+
const intl = useIntl();
9+
10+
const [count, setCount] = useState(0);
11+
12+
const increment = () => setCount(count + 1);
13+
const decrement = () => setCount(count - 1);
14+
15+
return (
16+
<div>
17+
<h2>
18+
<FormattedMessage id="counter.title" values={{ count }} />
19+
</h2>
20+
<button onClick={decrement}>
21+
{intl.formatMessage({id: 'counter.decrement'})} {/* Example of using the intl object */}
22+
</button>
23+
<button onClick={increment}>
24+
<FormattedMessage id="counter.increment" /> {/* Example of using the FormattedMessage component */}
25+
</button>
26+
</div>
27+
);
28+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
5+
:root {
6+
--background: #ffffff;
7+
--foreground: #171717;
8+
}
9+
10+
@media (prefers-color-scheme: dark) {
11+
:root {
12+
--background: #0a0a0a;
13+
--foreground: #ededed;
14+
}
15+
}
16+
17+
body {
18+
color: var(--foreground);
19+
background: var(--background);
20+
font-family: Arial, Helvetica, sans-serif;
21+
}
22+
23+
@layer utilities {
24+
.text-balance {
25+
text-wrap: balance;
26+
}
27+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { Metadata } from "next";
2+
import "./globals.css";
3+
import loadIntl from "@/i18n/server";
4+
import { IntlProvider } from "@/i18n/client";
5+
export const metadata: Metadata = {
6+
title: "Create Next App",
7+
description: "Generated by create next app",
8+
};
9+
10+
export default async function RootLayout(props: any) {
11+
const intl = await loadIntl(props.params.locale);
12+
13+
return (
14+
<IntlProvider locale={intl.locale} messages={intl.messages}>
15+
<html lang={intl.locale}>
16+
<body className="">
17+
{props.children}
18+
</body>
19+
</html>
20+
</IntlProvider>
21+
);
22+
}

0 commit comments

Comments
 (0)