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 · 6 comments
Open
1 of 6 tasks

Next.js is not supported ! #2657

boussaidev opened this issue Jan 1, 2025 · 6 comments
Assignees
Labels
bug Something isn't working gluestack-ui-unstyle Issue is due to gluestack-ui-unstyle High Priority Breaking change causing user project to crash. Require package release

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);

@Jao8
Copy link

Jao8 commented Jan 23, 2025

@Under-Warz It almost solved things for me, still getting

  ./node_modules/react-native-safe-area-context/lib/module/specs/NativeSafeAreaProvider.js:1:1
Module not found: Can't resolve 'react-native/Libraries/Utilities/codegenNativeComponent'
> 1 | import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2 | export default codegenNativeComponent('RNCSafeAreaProvider');
  3 | //# sourceMappingURL=NativeSafeAreaProvider.js.map



https://nextjs.org/docs/messages/module-not-found



./node_modules/react-native-safe-area-context/lib/module/specs/NativeSafeAreaView.js:1:1
Module not found: Can't resolve 'react-native/Libraries/Utilities/codegenNativeComponent'
> 1 | import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2 | export default codegenNativeComponent('RNCSafeAreaView', {
  3 |   interfaceOnly: true
  4 | });

any tips about that?

@alex-reusables
Copy link

@Under-Warz where is this documented? how did you arrive at this next-config? I cloned a Gluestack starter project (dashboard) and I have a similar but different next.config included in the project, but similarly there are an incredible amount of components that break the dev server as soon as I import them... This is the config from the dashboard starter project:

/** @type {import('next').NextConfig} */
const { DefinePlugin } = require("webpack");

module.exports = {
  reactStrictMode: true,
  transpilePackages: [
    "@gluestack-ui/nativewind-utils",
    "nativewind",
    "react-native-css-interop",
  ],
  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.alias["@unitools/router"] = "@unitools/router-next";
    config.resolve.alias["@unitools/image"] = "@unitools/image-next";
    config.resolve.alias["@unitools/link"] = "@unitools/link-next";
    config.resolve.extensions = [
      ".web.js",
      ".web.jsx",
      ".web.ts",
      ".web.tsx",
      ...config.resolve.extensions,
    ];

    config.plugins.push(
      new DefinePlugin({
        __DEV__: JSON.stringify(process.env.NODE_ENV !== "production"),
      })
    );

    return config;
  },
  typescript: { ignoreBuildErrors: true }
};

@akash3gtm
Copy link
Collaborator

can you let us know, which components break the app?

@akash3gtm
Copy link
Collaborator

Issue found, this is being worked on currently.
This will be fixed soon and updated here.

@akash3gtm akash3gtm assigned akash3gtm and unassigned vaibhk20 Feb 21, 2025
@akash3gtm akash3gtm added Require package release gluestack-ui-unstyle Issue is due to gluestack-ui-unstyle High Priority Breaking change causing user project to crash. labels Feb 21, 2025
@alex-reusables
Copy link

@akash3gtm drawer, select, tooltip are 3 I have tried that I quickly stopped using. Tooltip I eventually got to compile but the behaviour on screen is very odd, either it doesn't render or it flickers, I left a little video in Discord. It sounds like you have some leads on what's broken, I will watch this issue and if you want me to specifically recreate some errors and provide logs let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working gluestack-ui-unstyle Issue is due to gluestack-ui-unstyle High Priority Breaking change causing user project to crash. Require package release
Projects
Status: In Progress
Development

No branches or pull requests

6 participants