Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The @verida/account-web-vault package doesn't work in a Next.js application by default #427

Open
andy-verida opened this issue May 1, 2024 · 3 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@andy-verida
Copy link
Contributor

andy-verida commented May 1, 2024

Issue

When implementing Verida SSO on a Next.js app, we install the @verida/account-web-vault dependency. Upon running the application, there's an error loading the Sora font used by the login modal.

Workaround

Update the Next.js configuration to support loading static font files.

  • Install file-loader
yarn add -D file-loader
  • In the file next.config.mjs
const nextConfig = {
  webpack: (
    config,
    { buildId, dev, isServer, defaultLoaders, nextRuntime, webpack }
  ) => {
    config.module.rules.push({
      test: /\.(woff|woff2|eot|ttf|otf)$/,
      use: {
        loader: 'file-loader',
        options: {
          name: '[name].[ext]',
          publicPath: '/_next/static/fonts/',
          outputPath: `${isServer ? '../' : ''}static/fonts/`,
        },
      },
    });

    return config;
  }
}

Some solutions

  • Create an instruction for Next.js users
  • Create a dedicated @verida/account-web-vault-nextjs
  • How to identify a Next.js application and handle it in the code (not sure we can do that)
@andy-verida andy-verida added bug Something isn't working enhancement New feature or request labels May 1, 2024
@andy-verida andy-verida self-assigned this May 1, 2024
@andy-verida
Copy link
Contributor Author

Another issue, by default the login modal shows 2 QR codes at once, and the layout is broken.

Screenshot 2024-05-01 at 16 32 02

@aurelticot
Copy link
Member

@andy-verida what's the error with the font? Is the error raised by Next or is it the browser saying the font is missing? Or "just" the layout/content is broken?

In any case the modal should define the font-family with Sora as the first one but also generic names as fallback (like "sans-serif"), so that if the Sora font is not available, the browser will be able to manage.

Then, as the modal tries to load the Sora font from a certain URL. Yes, we could find a way that works for both Next and other implementation, and/or we could load the font from a external CDN.
If the above doesn't work, then we could give some instructions for developers integrating on Next.

@andy-verida
Copy link
Contributor Author

@aurelticot for now the app won't be built without that Next.js config.
I agree changing the font to load from CDN and having a fallback font is a better approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants