Skip to content

Commit 1070656

Browse files
committed
Refactor: Add wrapper components for dynamic imports and update deployment documentation
- Introduce wrapper components (`*Wrapper`) to simplify dynamic imports for client-side rendering. - Update README to include Netlify deployment instructions alongside Vercel. - Add `netlify.toml` for Netlify deployment support. - Install `@netlify/plugin-nextjs` as a dev dependency for Netlify compatibility.
1 parent e67b6d9 commit 1070656

File tree

14 files changed

+98
-37
lines changed

14 files changed

+98
-37
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ABLY_API_KEY=your_ably_api_key
2+
DEFAULT_CLIENT_ID=some_client_id

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The project uses the following components:
2323
### Prerequisites
2424

2525
1. [Sign up](https://ably.com/signup?utm_source=github&utm_medium=github-repo&utm_campaign=GLB-2211-ably-nextjs-fundamentals-kit&utm_content=ably-nextjs-fundamentals-kit&src=GLB-2211-ably-nextjs-fundamentals-kit-github-repo) or [log in](https://ably.com/login?utm_source=github&utm_medium=github-repo&utm_campaign=GLB-2211-ably-nextjs-fundamentals-kit&utm_content=ably-nextjs-fundamentals-kit&src=GLB-2211-ably-nextjs-fundamentals-kit-github-repo) to ably.com, and [create a new app and copy the API key](https://faqs.ably.com/setting-up-and-managing-api-keys?utm_source=github&utm_medium=github-repo&utm_campaign=GLB-2211-ably-nextjs-fundamentals-kit&utm_content=ably-nextjs-fundamentals-kit&src=GLB-2211-ably-nextjs-fundamentals-kit-github-repo).
26-
2. To deploy to [Vercel](https://vercel.com), create a Vercel account.
26+
2. To deploy, create an account on your chosen platform: [Vercel](https://vercel.com) or [Netlify](https://netlify.com).
2727

2828
### Configure the app
2929

@@ -37,16 +37,33 @@ echo "ABLY_API_KEY={YOUR_ABLY_API_KEY_HERE}">.env
3737

3838
```bash
3939
npm run dev
40-
# or
41-
yarn dev
4240
```
4341

44-
## Deploy on Vercel
42+
## Deploying
43+
44+
This app can be deployed to either Vercel or Netlify. The codebase is identical for both — only the platform-specific configuration files differ (`vercel.json` for Vercel, `netlify.toml` for Netlify).
45+
46+
### Deploy on Vercel
4547

4648
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.
4749

4850
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fably-labs%2Fably-nextjs-fundamentals-kit&env=ABLY_API_KEY)
4951

52+
1. Click the **Deploy with Vercel** button above.
53+
2. Set the `ABLY_API_KEY` environment variable when prompted.
54+
3. Click **Deploy**.
55+
56+
### Deploy on Netlify
57+
58+
You can deploy this app to [Netlify](https://www.netlify.com) using the button below. Netlify uses the `@netlify/plugin-nextjs` plugin (included in `devDependencies`) to handle Next.js server-side features such as API routes.
59+
60+
[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/ably-labs/ably-nextjs-fundamentals-kit)
61+
62+
1. Click the **Deploy to Netlify** button above.
63+
2. Connect your GitHub account and authorize Netlify to clone the repo.
64+
3. Set the `ABLY_API_KEY` environment variable in **Site configuration > Environment variables**.
65+
4. Trigger a deploy.
66+
5067
## Contributing
5168

5269
Want to help contributing to this project? Have a look at our [contributing guide](CONTRIBUTING.md)!
@@ -59,4 +76,4 @@ Want to help contributing to this project? Have a look at our [contributing guid
5976
- [Visit the Ably website](https://ably.com?utm_source=github&utm_medium=github-repo&utm_campaign=GLB-2211-ably-nextjs-fundamentals-kit&utm_content=ably-nextjs-fundamentals-kit&src=GLB-2211-ably-nextjs-fundamentals-kit-github-repo)
6077

6178
---
62-
[![Ably logo](https://static.ably.dev/badge-black.svg?ably-nextjs-fundamentals-kit-github-repo)](https://ably.com?utm_source=github&utm_medium=github-repo&utm_campaign=GLB-2211-ably-nextjs-fundamentals-kit&utm_content=ably-nextjs-fundamentals-kit&src=GLB-2211-ably-nextjs-fundamentals-kit-github-repo)
79+
[![Ably logo](https://static.ably.dev/badge-black.svg?ably-nextjs-fundamentals-kit-github-repo)](https://ably.com?utm_source=github&utm_medium=github-repo&utm_campaign=GLB-2211-ably-nextjs-fundamentals-kit&utm_content=ably-nextjs-fundamentals-kit&src=GLB-2211-ably-nextjs-fundamentals-kit-github-repo)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use client'
2+
3+
import dynamic from 'next/dynamic'
4+
5+
const AuthenticationClient = dynamic(
6+
() => import('./authentication-client.tsx'),
7+
{ ssr: false }
8+
)
9+
10+
export default function AuthenticationWrapper() {
11+
return <AuthenticationClient />
12+
}

app/authentication/page.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22
* Warning: Opening too many live preview tabs will slow down performance.
33
* We recommend closing them after you're done.
44
*/
5-
'use client'
65

76
import React from "react";
87
import "../global.css";
9-
import dynamic from 'next/dynamic';
108
import Sidebar from "../../components/Sidebar.tsx";
11-
12-
const AuthenticationClient = dynamic(() => import('./authentication-client.tsx'), {
13-
ssr: false,
14-
})
9+
import AuthenticationWrapper from './authentication-wrapper.tsx';
1510

1611
const Authentication = () => {
1712

@@ -21,7 +16,7 @@ const Authentication = () => {
2116
<>
2217
<Sidebar pageId={pageId} />
2318
<div className="flex flex-col grow pt-12 pr-12 pb-12 pl-12 rounded-2xl border-slate-100 border-t border-b border-l border-r border-solid border h-[864px] bg-slate-50">
24-
<AuthenticationClient />
19+
<AuthenticationWrapper />
2520
</div>
2621
</>
2722
)

app/history/history-wrapper.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use client'
2+
3+
import dynamic from 'next/dynamic'
4+
5+
const HistoryClient = dynamic(
6+
() => import('./history-client.tsx'),
7+
{ ssr: false }
8+
)
9+
10+
export default function HistoryWrapper() {
11+
return <HistoryClient />
12+
}

app/history/page.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,11 @@
22
* Warning: Opening too many live preview tabs will slow down performance.
33
* We recommend closing them after you're done.
44
*/
5-
'use client'
65

76
import React from "react";
87
import "../global.css";
9-
import dynamic from 'next/dynamic';
10-
import MenuFooter from "../../components/FooterItem.tsx";
11-
import MenuItem from "../../components/MenuItem.tsx";
128
import Sidebar from "../../components/Sidebar.tsx";
13-
14-
const HistoryClient = dynamic(() => import('./history-client.tsx'), {
15-
ssr: false,
16-
})
9+
import HistoryWrapper from './history-wrapper.tsx';
1710

1811
const History = () => {
1912

@@ -23,7 +16,7 @@ const History = () => {
2316
<>
2417
<Sidebar pageId={pageId} />
2518
<div className="flex flex-col grow gap-6 pt-12 pr-12 pb-12 pl-12 rounded-2xl border-slate-100 border-t border-b border-l border-r border-solid border h-[864px] bg-slate-50">
26-
<HistoryClient />
19+
<HistoryWrapper />
2720
</div>
2821
</>
2922
)

app/layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import './global.css'
22
import type { Metadata } from 'next'
3+
import React from "react";
34

45
export const metadata: Metadata = {
56
title: 'Ably & Next.js fundamentals kit',

app/presence/page.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,11 @@
22
* Warning: Opening too many live preview tabs will slow down performance.
33
* We recommend closing them after you're done.
44
*/
5-
'use client'
65

76
import React from "react";
87
import "../global.css";
9-
import dynamic from 'next/dynamic';
10-
import MenuFooter from "../../components/FooterItem.tsx";
11-
import MenuItem from "../../components/MenuItem.tsx";
128
import Sidebar from "../../components/Sidebar.tsx";
13-
14-
const PresenceClient = dynamic(() => import('./presence-client.tsx'), {
15-
ssr: false,
16-
})
9+
import PresenceWrapper from './presence-wrapper.tsx';
1710

1811
const Presence = () => {
1912

@@ -23,7 +16,7 @@ const Presence = () => {
2316
<>
2417
<Sidebar pageId={pageId} />
2518
<div className="flex flex-col grow gap-6 pt-12 pr-12 pb-12 pl-12 rounded-2xl border-slate-100 border-t border-b border-l border-r border-solid border h-[864px] bg-slate-50">
26-
<PresenceClient />
19+
<PresenceWrapper />
2720
</div>
2821
</>
2922
)

app/presence/presence-wrapper.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use client'
2+
3+
import dynamic from 'next/dynamic'
4+
5+
const PresenceClient = dynamic(
6+
() => import('./presence-client.tsx'),
7+
{ ssr: false }
8+
)
9+
10+
export default function PresenceWrapper() {
11+
return <PresenceClient />
12+
}

app/pub-sub/page.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22
* Warning: Opening too many live preview tabs will slow down performance.
33
* We recommend closing them after you're done.
44
*/
5-
'use client'
65

76
import React from "react";
87
import "../global.css";
9-
import dynamic from 'next/dynamic';
108
import Sidebar from "../../components/Sidebar.tsx";
11-
12-
const PubSubClient = dynamic(() => import('./pubsub-client.tsx'), {
13-
ssr: false,
14-
})
9+
import PubSubWrapper from './pubsub-wrapper.tsx';
1510

1611
const PubSub = () => {
1712

@@ -21,7 +16,7 @@ const PubSub = () => {
2116
<>
2217
<Sidebar pageId={pageId} />
2318
<div className="flex flex-col grow gap-6 pt-12 pr-12 pb-12 pl-12 rounded-2xl border-slate-100 border-t border-b border-l border-r border-solid border h-[864px] bg-slate-50">
24-
<PubSubClient />
19+
<PubSubWrapper />
2520
</div>
2621
</>
2722
)

0 commit comments

Comments
 (0)