2.0.0 • Published 2 years ago

@upstash/feedback v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Feedback Widget for Next.js

Create a Feedback Widget for your Next.js site with two steps. See the demo

1. Frontend

Install @upstash/feedback:

npm install @upstash/feedback

Import css and component:

// pages/_app.js

import '@upstash/feedback/dist/style.css'
import FeedbackWidget from '@upstash/feedback'

export default function MyApp({ Component, pageProps }) {
  return (
    <>
      <FeedbackWidget type="full" />
      <Component {...pageProps} />
    </>
  )
}

The options can be passed as React props

keytypedefaultaccept
user?string
metadata?objectnull
type?string"form"'form', 'rate', 'full'
apiPath?string'api/feedback'
themeColor?string'#5f6c72'
textColor?string'#ffffff'
titlestring, React.ReactElement
descriptionstring, React.ReactElement
showOnInitial?booleanfalse
children?React.ReactElement

2. Backend

The data will be kept at Upstash Redis. Create a free Redis database at Upstash Console

Install @upstash/redis:

npm install @upstash/redis

Create API:

// pages/api/feedback.js

import { Redis } from '@upstash/redis'

const redis = new Redis({
  url: 'UPSTASH_REDIS_REST_URL',
  token: 'UPSTASH_REDIS_REST_TOKEN'
})

export default async function FeedbackWidgetAPI(req, res) {
  try {
    await redis.hset('feedback', Date.now(), req.body)
    return res.status(200).json({ message: 'success' })
  } catch (err) {
    return res.status(400).json({ message: err })
  }
}

UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN can be found at the database details page in Upstash Console.

Data Administration

The submitted forms can be managed on Upstash Console Integrations page.

Submitting the User Id

If you already have an id (or email) for the current user, you can pass it to the component as a parameter, so the feedback will be stored together with the user's id.

<FeedbackWidget type="full" user={currentUser.email}/>

Also, you can set a user id just to hide email input, so the form can be submitted anonymously.

<FeedbackWidget type="full" user="anything"/>
2.0.0

2 years ago

1.0.0

2 years ago

0.2.1

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.0

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.32

2 years ago

0.0.31

2 years ago

0.0.3

2 years ago

0.0.2-beta.22

2 years ago

0.0.2-beta.21

2 years ago

0.0.2-beta.20

2 years ago

0.0.2-beta.19

2 years ago

0.0.2-beta.18

2 years ago

0.0.2-beta.17

2 years ago

0.0.2-beta.16

2 years ago

0.0.2-beta.15

2 years ago

0.0.2-beta.14

2 years ago

0.0.2-beta.13

2 years ago

0.0.2-beta.12

2 years ago

0.0.2-beta.11

2 years ago

0.0.2-beta.10

2 years ago

0.0.2-beta.9

2 years ago

0.0.2-beta.8

2 years ago

0.0.2-beta.7

2 years ago

0.0.2-beta.6

2 years ago

0.0.2-beta.5

2 years ago

0.0.2-beta.4

2 years ago

0.0.2-beta.3

2 years ago

0.0.2-beta.2

2 years ago

0.0.2-beta.1

2 years ago

0.0.2-beta.0

2 years ago