-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Update nextjs demo and installation guides
- Loading branch information
Showing
17 changed files
with
338 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@data-client/ssr': patch | ||
--- | ||
|
||
Update README to include DataProvider (app routes) docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import Link from 'next/link'; | ||
import UserSelection from '../../components/todo/UserSelection'; | ||
|
||
export default function TodoLayout({ | ||
children, | ||
params, | ||
}: { | ||
children: React.ReactNode; | ||
params?: { userId: number }; | ||
}) { | ||
return ( | ||
<> | ||
<title>NextJS + Reactive Data Client = ❤️</title> | ||
<meta | ||
name="description" | ||
content="NextJS integration with Reactive Data Client" | ||
/> | ||
|
||
<UserSelection userId={params?.userId} /> | ||
|
||
{children} | ||
|
||
<p> | ||
No fetch requests took place on the client. The client is immediately | ||
interactive without the need for revalidation. | ||
</p> | ||
|
||
<p> | ||
This is because Reactive Data Client's store is initialized and{' '} | ||
<a href="https://dataclient.io/docs/concepts/normalization"> | ||
normalized | ||
</a> | ||
</p> | ||
|
||
<p> | ||
<Link href="/crypto">Live BTC Price</Link> | ||
</p> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use client'; | ||
import TodoList from '../../components/todo/TodoList'; | ||
|
||
export default function TodoPage({ params }: { params: { userId: number } }) { | ||
return ( | ||
<TodoList {...params} /> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use client'; | ||
import Link from 'next/link'; | ||
|
||
import AssetPrice from '../../components/AssetPrice'; | ||
import styles from '../../styles/Home.module.css'; | ||
|
||
export default function Crypto() { | ||
return ( | ||
<> | ||
<title>Live Crypto Prices with Reactive Data Client</title> | ||
<meta | ||
name="description" | ||
content="Live BTC price using the Reactive Data Client" | ||
/> | ||
|
||
<h2 className={styles.subtitle}> | ||
Here we show the live price of BTC using Reactive Data Client | ||
</h2> | ||
|
||
<p className={styles.price}> | ||
<AssetPrice symbol="BTC" /> | ||
</p> | ||
|
||
<p> | ||
The latest price is immediately available before any JavaScript runs; | ||
while automatically updating as prices change. | ||
</p> | ||
|
||
<p> | ||
<Link href="/">Todo List</Link> | ||
</p> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { AsyncBoundary } from '@data-client/react'; | ||
import { DataProvider } from '@data-client/ssr/nextjs'; | ||
import Image from 'next/image'; | ||
|
||
import styles from '../styles/Home.module.css'; | ||
|
||
export default function Layout({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<html lang="en"> | ||
<head> | ||
<link rel="icon" href="/favicon.ico" /> | ||
</head> | ||
<body> | ||
<DataProvider> | ||
<div className={styles.container}> | ||
<main className={styles.main}> | ||
<h1 className={styles.title}> | ||
Welcome to <a href="https://nextjs.org">Next.js!</a> with{' '} | ||
<a href="https://dataclient.io">Reactive Data Client</a> | ||
</h1> | ||
|
||
<AsyncBoundary>{children}</AsyncBoundary> | ||
</main> | ||
|
||
<footer className={styles.footer}> | ||
<a | ||
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Powered by{' '} | ||
<span className={styles.logo}> | ||
<Image | ||
src="/vercel.svg" | ||
alt="Vercel Logo" | ||
width={72} | ||
height={16} | ||
/> | ||
</span> | ||
</a> | ||
</footer> | ||
</div> | ||
</DataProvider> | ||
</body> | ||
</html> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import TodoLayout from './[userId]/layout'; | ||
import TodoPage from './[userId]/page'; | ||
|
||
export default function Home() { | ||
return ( | ||
<TodoLayout params={{ userId: 1 }}> | ||
<TodoPage params={{ userId: 1 }} /> | ||
</TodoLayout> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.userLink { | ||
display: inline-block; | ||
text-decoration: none; | ||
margin: 0 7px; | ||
color: blue; | ||
|
||
} | ||
.userLink.active { | ||
color: red; | ||
} | ||
.userLink:hover { | ||
text-decoration: underline; | ||
} | ||
|
||
.wrap { | ||
margin-top: 20px; | ||
text-align: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use client'; | ||
import { useSuspense } from '@data-client/react'; | ||
import { UserResource } from '../../resources/UserResource'; | ||
import Link from 'next/link'; | ||
import styles from './UserSelect.module.css'; | ||
import clsx from 'clsx'; | ||
|
||
export default function UserSelection({ userId }: { userId?: number }) { | ||
const users = useSuspense(UserResource.getList).slice(0, 7); | ||
return ( | ||
<div className={styles.wrap}> | ||
{users.map(user => ( | ||
<Link | ||
key={user.pk()} | ||
href={`/${user.id === 1 ? '' : user.id}`} | ||
className={clsx(styles.userLink, { | ||
[styles.active]: user.id == userId, | ||
})} | ||
> | ||
{user.name} | ||
</Link> | ||
))} | ||
</div> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.