Skip to content

Commit

Permalink
examples: Update basic example to Next.js 15. (#9440)
Browse files Browse the repository at this point in the history
### Description

As the title says, updating to Next.js 15 in `basic` so `create-turbo`
gives people the latest and greatest.

I've also taken the time to:
- Make the content of the applications Turborepo
- Added a `check-types` task for folks who are interested in running
TypeScript checks.

### Testing Instructions

Our examples CI should make sure things are still building correctly.
Would appreciate if someone could open it up in their editor and see if
they get any squiggly lines, as well!
  • Loading branch information
anthonyshew authored Nov 15, 2024
1 parent 825b6f1 commit 39f94e9
Show file tree
Hide file tree
Showing 19 changed files with 3,774 additions and 2,798 deletions.
11 changes: 11 additions & 0 deletions examples/basic/apps/docs/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,19 @@ a {
text-decoration: none;
}

.imgDark {
display: none;
}

@media (prefers-color-scheme: dark) {
html {
color-scheme: dark;
}

.imgLight {
display: none;
}
.imgDark {
display: unset;
}
}
51 changes: 27 additions & 24 deletions examples/basic/apps/docs/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
import Image from "next/image";
import Image, { type ImageProps } from "next/image";
import { Button } from "@repo/ui/button";
import styles from "./page.module.css";

type Props = Omit<ImageProps, "src"> & {
srcLight: string;
srcDark: string;
};

const ThemeImage = (props: Props) => {
const { srcLight, srcDark, ...rest } = props;

return (
<>
<Image {...rest} src={srcLight} className="imgLight" />
<Image {...rest} src={srcDark} className="imgDark" />
</>
);
};

export default function Home() {
return (
<div className={styles.page}>
<main className={styles.main}>
<Image
<ThemeImage
className={styles.logo}
src="/next.svg"
alt="Next.js logo"
srcLight="turborepo-dark.svg"
srcDark="turborepo-light.svg"
alt="Turborepo logo"
width={180}
height={38}
priority
/>
<ol>
<li>
Get started by editing <code>app/page.tsx</code>
Get started by editing <code>apps/docs/app/page.tsx</code>
</li>
<li>Save and see your changes instantly.</li>
</ol>

<div className={styles.ctas}>
<a
className={styles.primary}
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
href="https://vercel.com/new/clone?demo-description=Learn+to+implement+a+monorepo+with+a+two+Next.js+sites+that+has+installed+three+local+packages.&demo-image=%2F%2Fimages.ctfassets.net%2Fe5382hct74si%2F4K8ZISWAzJ8X1504ca0zmC%2F0b21a1c6246add355e55816278ef54bc%2FBasic.png&demo-title=Monorepo+with+Turborepo&demo-url=https%3A%2F%2Fexamples-basic-web.vercel.sh%2F&from=templates&project-name=Monorepo+with+Turborepo&repository-name=monorepo-turborepo&repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fturborepo%2Ftree%2Fmain%2Fexamples%2Fbasic&root-directory=apps%2Fdocs&skippable-integrations=1&teamSlug=vercel&utm_source=create-turbo"
target="_blank"
rel="noopener noreferrer"
>
Expand All @@ -38,7 +55,7 @@ export default function Home() {
Deploy now
</a>
<a
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
href="https://turbo.build/repo/docs?utm_source"
target="_blank"
rel="noopener noreferrer"
className={styles.secondary}
Expand All @@ -52,21 +69,7 @@ export default function Home() {
</main>
<footer className={styles.footer}>
<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
aria-hidden
src="/file-text.svg"
alt="File icon"
width={16}
height={16}
/>
Learn
</a>
<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
href="https://vercel.com/templates?search=turborepo&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Expand All @@ -80,7 +83,7 @@ export default function Home() {
Examples
</a>
<a
href="https://nextjs.org?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
href="https://turbo.build?utm_source=create-turbo"
target="_blank"
rel="noopener noreferrer"
>
Expand All @@ -91,7 +94,7 @@ export default function Home() {
width={16}
height={16}
/>
Go to nextjs.org
Go to turbo.build
</a>
</footer>
</div>
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/apps/docs/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
17 changes: 9 additions & 8 deletions examples/basic/apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev --turbo --port 3001",
"dev": "next dev --turbopack",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"check-types": "tsc --noEmit"
},
"dependencies": {
"@repo/ui": "workspace:*",
"next": "14.2.6",
"react": "18.3.1",
"react-dom": "18.3.1"
"next": "15.0.3",
"react": "19.0.0-rc-66855b96-20241106",
"react-dom": "19.0.0-rc-66855b96-20241106"
},
"devDependencies": {
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/react": "18.3.1",
"@types/react-dom": "18.3.0",
"eslint": "^8",
"eslint-config-next": "14.2.6",
"eslint-config-next": "15.0.3",
"typescript": "5.5.4"
}
}
19 changes: 19 additions & 0 deletions examples/basic/apps/docs/public/turborepo-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions examples/basic/apps/docs/public/turborepo-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions examples/basic/apps/web/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,19 @@ a {
text-decoration: none;
}

.imgDark {
display: none;
}

@media (prefers-color-scheme: dark) {
html {
color-scheme: dark;
}

.imgLight {
display: none;
}
.imgDark {
display: unset;
}
}
51 changes: 27 additions & 24 deletions examples/basic/apps/web/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
import Image from "next/image";
import Image, { type ImageProps } from "next/image";
import { Button } from "@repo/ui/button";
import styles from "./page.module.css";

type Props = Omit<ImageProps, "src"> & {
srcLight: string;
srcDark: string;
};

const ThemeImage = (props: Props) => {
const { srcLight, srcDark, ...rest } = props;

return (
<>
<Image {...rest} src={srcLight} className="imgLight" />
<Image {...rest} src={srcDark} className="imgDark" />
</>
);
};

export default function Home() {
return (
<div className={styles.page}>
<main className={styles.main}>
<Image
<ThemeImage
className={styles.logo}
src="/next.svg"
alt="Next.js logo"
srcLight="turborepo-dark.svg"
srcDark="turborepo-light.svg"
alt="Turborepo logo"
width={180}
height={38}
priority
/>
<ol>
<li>
Get started by editing <code>app/page.tsx</code>
Get started by editing <code>apps/web/app/page.tsx</code>
</li>
<li>Save and see your changes instantly.</li>
</ol>

<div className={styles.ctas}>
<a
className={styles.primary}
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
href="https://vercel.com/new/clone?demo-description=Learn+to+implement+a+monorepo+with+a+two+Next.js+sites+that+has+installed+three+local+packages.&demo-image=%2F%2Fimages.ctfassets.net%2Fe5382hct74si%2F4K8ZISWAzJ8X1504ca0zmC%2F0b21a1c6246add355e55816278ef54bc%2FBasic.png&demo-title=Monorepo+with+Turborepo&demo-url=https%3A%2F%2Fexamples-basic-web.vercel.sh%2F&from=templates&project-name=Monorepo+with+Turborepo&repository-name=monorepo-turborepo&repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fturborepo%2Ftree%2Fmain%2Fexamples%2Fbasic&root-directory=apps%2Fdocs&skippable-integrations=1&teamSlug=vercel&utm_source=create-turbo"
target="_blank"
rel="noopener noreferrer"
>
Expand All @@ -38,7 +55,7 @@ export default function Home() {
Deploy now
</a>
<a
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
href="https://turbo.build/repo/docs?utm_source"
target="_blank"
rel="noopener noreferrer"
className={styles.secondary}
Expand All @@ -52,21 +69,7 @@ export default function Home() {
</main>
<footer className={styles.footer}>
<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
aria-hidden
src="/file-text.svg"
alt="File icon"
width={16}
height={16}
/>
Learn
</a>
<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
href="https://vercel.com/templates?search=turborepo&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Expand All @@ -80,7 +83,7 @@ export default function Home() {
Examples
</a>
<a
href="https://nextjs.org?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
href="https://turbo.build?utm_source=create-turbo"
target="_blank"
rel="noopener noreferrer"
>
Expand All @@ -91,7 +94,7 @@ export default function Home() {
width={16}
height={16}
/>
Go to nextjs.org
Go to turbo.build
</a>
</footer>
</div>
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/apps/web/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
17 changes: 9 additions & 8 deletions examples/basic/apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev --turbo",
"dev": "next dev --turbopack",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"check-types": "tsc --noEmit"
},
"dependencies": {
"@repo/ui": "workspace:*",
"next": "14.2.6",
"react": "18.3.1",
"react-dom": "18.3.1"
"next": "15.0.3",
"react": "19.0.0-rc-66855b96-20241106",
"react-dom": "19.0.0-rc-66855b96-20241106"
},
"devDependencies": {
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/react": "18.3.1",
"@types/react-dom": "18.3.0",
"eslint": "^8",
"eslint-config-next": "14.2.6",
"eslint-config-next": "15.0.3",
"typescript": "5.5.4"
}
}
Loading

0 comments on commit 39f94e9

Please sign in to comment.