Build your own visual editor in 5 minutes
cd
into the project directory and install the following packages:
.env.local
file and add your Embed’s private key.
Client
which we’ll use to perform priviledged operations such as authenticating our users into our new embedded Mirin editor.
Typically, this will live in your backend and you would create API endpoints to interface with the Client
. In Next.js 15, we can use server actions without having to create a separate backend:
Client
- so let’s create a new server action to do just that:
documentId
argument which our page on the frontend will pass, and we’re generating a valid token that effectively grants the user access to the edit the document on our Editor.
In a real app, you probably want to add additional logic here - e.g. to check if your user has the correct permissions to edit a given document.
TheFinally, let’s create a new page in our project where we’ll render our editor.client.authorize()
method accepts a context object, by default - this object is used to specify thedocumentId
to grant the user access to edit.