-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add next.js & remix guide + update main getting-started guide
- Loading branch information
Showing
3 changed files
with
168 additions
and
10 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { siteTitle } from '../globals.ts'; | ||
|
||
export const meta = [ | ||
{ | ||
title: `Usage with Remix | ${siteTitle}`, | ||
description: 'How to use @pheralb/toast library with Remix', | ||
}, | ||
]; | ||
|
||
# Usage with Remix | ||
|
||
How to use the library with [Remix **v2** with Vite](https://remix.run/). | ||
|
||
1. Create a new Remix project: | ||
|
||
```bash | ||
npx create-remix@latest | ||
``` | ||
|
||
2. Select the default options: | ||
|
||
```bash | ||
remix v2.x.x 💿 Let's build a better website... | ||
dir Where should we create your new project? | ||
remix-project | ||
git Initialize a new git repository? | ||
Yes | ||
deps Install dependencies with npm? | ||
Yes | ||
done That's it! | ||
``` | ||
|
||
3. Install the library: | ||
|
||
```bash | ||
npm install @pheralb/toast | ||
``` | ||
|
||
4. Add the [`ToastProvider`](/provider) to the `root.tsx` file: | ||
|
||
```tsx | ||
// 📃 root.tsx | ||
import { ToastProvider } from '@pheralb/toast'; | ||
|
||
export function Layout({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<html lang="en"> | ||
<head> | ||
<meta charSet="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<Meta /> | ||
<Links /> | ||
</head> | ||
<body> | ||
<ToastProvider>{children}</ToastProvider> | ||
<ScrollRestoration /> | ||
<Scripts /> | ||
</body> | ||
</html> | ||
); | ||
} | ||
|
||
export default function App() { | ||
return <Outlet />; | ||
} | ||
``` | ||
|
||
5. Use the [`useToast`](/useToast) hook in your components or pages: | ||
|
||
```tsx | ||
// 📃 index.tsx | ||
import { useToast } from '@pheralb/toast'; | ||
|
||
export default function Index() { | ||
const toast = useToast(); | ||
return ( | ||
<> | ||
<h1>✨ Show a toast:</h1> | ||
<button | ||
onClick={() => | ||
toast.success({ | ||
text: 'Ready 🚀✨', | ||
}) | ||
} | ||
> | ||
Show toast | ||
</button> | ||
</> | ||
); | ||
} | ||
``` | ||
|
||
✨ Ready. |