Next.js doesn't work properly in Safari

See original GitHub issue

When I try to run my next app on Safari, I get this error in the console and it makes the app not function properly.

SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode.

System information

  • OS: macOS
  • Browser: Safari Version 9.1.2 (11601.7.7)
  • Version of Next.js: 6.1.0

Additional context

I’ve searched online and found the same issue with no solution, the only reasonable solution was to use babel.js - browser targets, however that breaks the app badly and it doesn’t even build.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
paschaldevcommented, Jul 30, 2018

Just leaving this here for anybody who stumbles upon this same issue. I added this to my next.config.js file and everything works fine on Safari, it no longer includes the const keyword.

webpack(config, options) {
	...
	config.module.rules.push(
		{
			test: /\.js$/,
			include: [
				/node_modules/
			],
			loader: 'babel-loader'
		}
	)
}

What this does is transpile every js file imported in our app with our babel configuration. Looks like a very lazy fix but solves the problem for me.

0reactions
timneutkenscommented, Jul 27, 2018

Or use next-cookies npmjs.com/next-cookies

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why my nextjs app doesn't work on Safari? - Stack Overflow
I'm developing a web app using nextjs. Everything works just fine on every browser, except for Safari on Mac. This is what I...
Read more >
Supported Browsers and Features - Next.js
Supported Browsers and Features. Next.js supports modern browsers with zero configuration. Chrome 64+; Edge 79+; Firefox 67+; Opera 51+; Safari 12+ ...
Read more >
ReactJS web app renders blank page on iPhone
The web app functions normally on every user device except on iPhone users, both chrome and safari render a blank page. I've tried...
Read more >
NextJS website not working on iOS devices - Reddit
This likely has nothing to do with Next.js. If the appearance is wrong on iOS devices, then you almost certainly have broken styling...
Read more >
React/Next.js site doesn't load properly in Safari (blank page)
[Solved]-React/Next.js site doesn't load properly in Safari (blank page)-Reactjs ... For me it was a simple hard refresh (CTRL + SHIFT + R)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found