Soft launchDialecto is still in testing, and details on this site may change as we finish it.

Next.js live editing

Live editing on Next.js lets you click a text on your running dev app and edit it in a Dialecto sidebar. It runs under next dev only. The add-on’s tests cover the App Router and the Pages Router, with messages loaded through next-intl.

Install

npm install --save-dev @dialecto/in-context

Setup

Three edits turn it on.

  1. Wrap your Next.js config. The handler that serves the editor starts in the development server only.

    // next.config.mjs
    import { withDialectoInContext } from '@dialecto/in-context/next';
    
    export default withDialectoInContext(config, { project: '12' });
  2. Mark your messages once, where you load them.

    // i18n/request.js
    import { markMessages } from '@dialecto/in-context/next';
    
    messages: await markMessages(messages, { domain: 'messages', locale })
  3. Add the DialectoInContext component to the layout, or to pages/_document on the Pages Router.

    // app/layout.jsx
    import { DialectoInContext } from '@dialecto/in-context/next';
    
    <DialectoInContext />

Run next dev. The component renders nothing in a production build.

The messages live in messages/<locale>.json by default, as nested JSON. A locale that lacks a message can fall back to your source locale: mergeMessages, exported next to markMessages, merges the fallback in before you mark the tree.

Editable text

You can edit any text from the messages you wrapped, in Server Components and Client Components. A message with an argument, such as Hello {name}, previews with the value the page used, and after a reload the draft shows on the page.

Settings

An option passed to withDialectoInContext wins over the environment variable.

Option Variable Default
url DIALECTO_URL https://app.dialecto.eu
project DIALECTO_PROJECT none
catalogs DIALECTO_CATALOGS messages
toggleKey DIALECTO_TOGGLE_KEY none
corner DIALECTO_CORNER none
hidden DIALECTO_HIDDEN off
port DIALECTO_DEV_PORT the port next dev runs on, else 3000

DIALECTO_IN_CONTEXT=off turns the add-on off.

Pull requests

Your edits are saved in Dialecto as drafts on your project. The pull request is opened from the sidebar, and your team reviews and merges it the usual way.

Safety

  • The handler starts only in the development server. next build and next start ship no markers, no overlay and no route.
  • The handler listens on 127.0.0.1 only, even when you start next dev with -H 0.0.0.0. It answers 403 without its per-session token, even to the dev page’s own origin.