Skip to content

Usage outside a next.js app (in shared/ui) #1216

Answered by zaaakher
TheMikeyRoss asked this question in Q&A
Discussion options

You must be logged in to vote

You can pass the t as prop to your shared/ui components

export const TranslatedComponent = ({ t }) => {
  return (
    <div>
      <Button>{t("common:back")}</Button>
      <Button>{t("common:home")}</Button>
      <Button>{t("common:save")}</Button>
    </div>
  );
};

And in your next.js app:

export const SomePage = () => {
  const { t } = useTranslation('common')
  return (
      <TranslatedComponent t={t}/>
  )
}

Replies: 5 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@TheMikeyRoss
Comment options

@aralroca
Comment options

@TheMikeyRoss
Comment options

@aralroca
Comment options

@TheMikeyRoss
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by TheMikeyRoss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants