Skip to content

Commit

Permalink
docs(examples/with-iron-session): fix mutate + fetch, add TypeScript …
Browse files Browse the repository at this point in the history
…example link (#25889)

This updates the with-iron-session example with:
- updated way to mutate + fetch (re: vvo/iron-session#329)
- updated readme to include TypeScript example link

Requirements:
- [x] Make sure the linting passes
  • Loading branch information
vvo committed Jun 8, 2021
1 parent ca2921f commit 5072518
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
21 changes: 14 additions & 7 deletions examples/with-iron-session/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
# Example application using [`next-iron-session`](https://github.com/vvo/next-iron-session)

---

<p align="center"><b>Online demo at <a href="https://next-iron-session.vercel.app/">https://next-iron-session.vercel.app/</a> 👀</b></p>

---

This example creates an authentication system that uses a **signed and encrypted cookie to store session data**. It relies on [`next-iron-session`](https://github.com/vvo/next-iron-session).

It uses current best practices for authentication in the Next.js ecosystem.

On the next-iron-session repository (https://github.com/vvo/next-iron-session) you'll find:

- full API documentation and explanations on how it works
- [TypeScript example](https://github.com/vvo/next-iron-session/tree/master/examples/next-typescript)
- [JavaScript example](https://github.com/vvo/next-iron-session/tree/master/examples/next.js)
- [Express.js example](https://github.com/vvo/next-iron-session/tree/master/examples/express)

**Features:**

- [Static Generation](https://nextjs.org/docs/basic-features/pages#static-generation-recommended) (SG), recommended example
Expand All @@ -15,13 +28,7 @@ It uses current best practices for authentication in the Next.js ecosystem.
[`next-iron-session`](https://github.com/vvo/next-iron-session) also supports:

- Express / Connect middlewares
- Multiple encryption keys (password) to allow for seamless updates or just password rotation

---

<p align="center"><b>Online demo at <a href="https://next-iron-session.vercel.app/">https://next-iron-session.vercel.app/</a> 👀</b></p>

---
- Multiple encryption keys (passwords) to allow for seamless updates or just password rotation

## Deploy your own

Expand Down
4 changes: 2 additions & 2 deletions examples/with-iron-session/pages/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const Login = () => {
}

try {
await mutateUser(
fetchJson('/api/login', {
mutateUser(
await fetchJson('/api/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
Expand Down

0 comments on commit 5072518

Please sign in to comment.