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

Next.js is not supported ! #2657

Open
1 of 6 tasks
boussaidev opened this issue Jan 1, 2025 · 1 comment
Open
1 of 6 tasks

Next.js is not supported ! #2657

boussaidev opened this issue Jan 1, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@boussaidev
Copy link

Description

Next.js is not supported getting a lot of errors when using ui with latest nextjs project

CodeSandbox/Snack link

https://codesandbox.com/

Steps to reproduce

next js is not supported !
Next.js is not supported
getting a lot of errors when using ui with latest nextjs project
Screenshot 2025-01-01 at 20 32 37

gluestack-ui Version

latest

Platform

  • Expo
  • React Native CLI
  • Next
  • Web
  • Android
  • iOS

Other Platform

No response

Additional Information

No response

@Under-Warz
Copy link

Under-Warz commented Jan 2, 2025

@boussaidev add this to your next.config.ts

You have to configure react-native-web to alias all react-native import with react-native-web

import { withGluestackUI } from "@gluestack/ui-next-adapter";
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
	transpilePackages: [
		"react-native-reanimated",
		"nativewind",
		"react-native-css-interop",
		"@gluestack-ui/nativewind-utils",
		"@gluestack-ui/icon",
		"@gluestack-ui/button",
		"@gluestack-ui/utils",
		"@gluestack-ui/toast",
		"@gluestack-ui/overlay",
	],
	experimental: {
		turbo: {
			resolveAlias: {
				"react-native": "react-native-web",
			},
			resolveExtensions: [
				".web.js",
				".web.jsx",
				".web.ts",
				".web.tsx",
				".mdx",
				".tsx",
				".ts",
				".jsx",
				".js",
				".mjs",
				".json",
			],
		},
	},
	webpack: (config) => {
		config.resolve.alias = {
			...(config.resolve.alias || {}),
			// Transform all direct `react-native` imports to `react-native-web`
			"react-native$": "react-native-web",
		};
		config.resolve.extensions = [
			".web.js",
			".web.jsx",
			".web.ts",
			".web.tsx",
			...config.resolve.extensions,
		];
		return config;
	},
};

export default withGluestackUI(nextConfig);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

3 participants