Next.js Discord

Discord Forum

I want to make a Language Selector, that safes the selected language with a Cookie

Unanswered
Tonkinese posted this in #help-forum
Open in Discord
TonkineseOP
Can anyone help me with that:

"use client"
import setLanguage from 'next-translate/setLanguage';

const LanguageSwitcher = () => {
    return (
        <button onClick={() => setLanguage('de')}>Deutsch</button>
    );
};

export default LanguageSwitcher;


Error
Error: No router instance found.
You should only use "next/router" on the client side of your app.

Source
src\app\components\LanguageSwitcher.js (6:43) @ onClick

  4 | const LanguageSwitcher = () => {
  5 | return (
> 6 |     <button onClick={() => setLanguage('de')}>Deutsch</button>
    |                                       ^
  7 | );
  8 | };

0 Replies