• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

158
Views
Is there a way to use the screenfull javascript library within the Nextjs framework?

I've been trying to use Dynamic Importing in Nextjs in order to use the screenfull library but it hasn't worked.

import dynamic from "next/dynamic"
import screenfull from 'screenfull';
const Screenfull = dynamic(()=>{return import("screenfull")},{})
almost 3 years ago · Juan Pablo Isaza
3 answers
Answer question

0

you can create file in @utils folder with below code:

import screenfull from 'screenfull';

export default screenfull

then in your component do something like so:

import dynamic from 'next/dynamic';
const screenful = dynamic(() => import('../@utils/screenfull'))

almost 3 years ago · Juan Pablo Isaza Report

0

The first question that comes to mind is what's the error you're getting? There's no reason you shouldn't be able to import any library you've installed locally! Did you actually install that package by running npm install screenfull on your terminal?

almost 3 years ago · Juan Pablo Isaza Report

0

You're using dynamic imports incorrectly. The idea is that you can import part of a JS module inside of another piece of JS code, so you don't have to preload or load the entire library. An example might be doing a dynamic import after an async call.

Next has some other great examples of how to use this functionality in your application.

almost 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error