Device width is invalid by default
Yeah, you're right, actually, there is no option to select the default device... For now, as a workaround, do it manually after init: And as you're using the mobile-first approach, you would need to fix your Desktop device: In the next release, I'll add the default option in the device manager configuration
Read full answer below ↓Question
Thanks for #3673
I have a new bug feedback.
Version:. 0.17.22
Are you able to reproduce the bug from the demo?
- [* ] Yes
- No
What is the expected behavior? I want the default to be the width of the mobile device, so I configured min-width priority, but only the mobile width is displayed by default on the select box, and the page width has not changed. I use editor.setDevice('Mobile'); Yes, but in the new page management, the new page is also the same, I continue to use this method is invalid, so I think there should be a better way to deal with it.
Describe the bug detailed
What is the current behavior?
Describe the bug detailed
Are you able to attach screenshots, screencasts or a live demo?
- [* ] Yes (attach)
- No
var editor = grapesjs.init({
...
mediaCondition: 'min-width',
deviceManager: {
devices: [{
name: 'Mobile',
width: '375px', // this value will be used on canvas width
widthMedia: '', // this value will be used in CSS @media
},{
name: 'Desktop',
width: '', // default size
widthMedia: '', // this value will be used in CSS @media
}]
},
...
})

Answers (2)
Yeah, you're right, actually, there is no option to select the default device... For now, as a workaround, do it manually after init:
const editor = grapesjs.init({...});
editor.setDevice('Mobile');
And as you're using the mobile-first approach, you would need to fix your Desktop device:
{
name: 'Desktop',
width: '', // default size
widthMedia: '376px', // Tells the editor which media to apply for bigger screens
}
In the next release, I'll add the default option in the device manager configuration
deviceManager: {
// The device `id` to select on start, if not indicated, the first available from `devices` will be used.
default: 'Mobile',
devices: [...],
},
Thanks for reporting this, @imouou.
The issue with Device width is invalid by default appears to be a race condition or state management timing problem. This typically happens when component lifecycle events and DOM modifications overlap, creating an inconsistent state.
What to try:
- Add a setTimeout wrapper to ensure the DOM has settled:
setTimeout(() => {
// your operation here
}, 0);
-
Check initialization order — make sure components are fully loaded before you interact with them
-
Use the editor's event system — listen to completion events:
editor.on('component:mount', (component) => {
// safe to interact with component here
});
Recommended next steps:
- Test with the latest GrapesJS version if you haven't
- Provide a minimal reproducible example (CodeSandbox) — this helps the team identify the root cause faster
- Include GrapesJS version, browser, and console errors in your report
Related Questions and Answers
Continue research with similar issue discussions.
Issue #5083
Blocks are not draggable to canvas
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Tauri Reproducible demo link Describe the...
Issue #6549
Couldnt Resize image
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Chrome Reproducible demo link https://code...
Issue #3454
RTE insert link does not update DOM
Version: "0.17.3" Are you able to reproduce the bug from the demo?[X] Yes[ ] No What is the expected behavior? After inserting link using d...
Issue #4208
Style click state bug in every element
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Brave Last, tested on chrome last and Safa...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Related tutorials
In-depth guides on the same topic.
Tutorial
Find the Right GrapesJS Plugin in Seconds: Smarter Discovery Is Live
We're shipping a set of discovery upgrades. New label filters, a proper compatibility switch for GrapesJS vs Studio, one-click and a smarter sort bar.
Tutorial
GrapesJS vs Webflow vs Tilda: What to Choose for Your Business in 2026
Choosing the right website platform in 2026 is no longer just about building a site
Tutorial
GJS Market 2.0 - Donations, Tracking, Labels and Better Product Discovery
We’ve rolled out a new set of GrapesJS marketplace updates across GJS Market, focused on improving how creators distribute products
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.