Use With
Setting up Twind for seamless integration in a Next.js project.
- 📝 Inspect the example
- 📓 Consult the API reference
- 📜 Read the changelog
🤝 Compatibility
@twind/with-next | next |
---|---|
>=1.0.0 <2 | 12.x , 13.x |
> Next 13 app directory is currently not supported. Please use the legacy app directory for now.
📦 Installation
-
Install from npm
@twind/core
and@twind/with-next
are available on npm and need to be installed together. -
Define the configuration
Using an extra file,
twind.config.js
, allows some tools like IntelliSense to find your configuration. -
Load Twind in the App component
install
creates and registers a twind instance that will generate the styles. This allows third-party packages to importtw
from the twind package and get the same instance.If you are using a custom App component you need to pass the it to
install
. -
Enable Twind in Document component
Enable server-side rendering of all the styles that are used within the HTML and sending them to the client.
If you are using a custom Document component you need to pass the it to
install
. -
Optional: Install and configure the recommended presets
@twind/preset-autoprefix
and@twind/preset-tailwind
.Install the presets
All presets are available on npm.
Configure the presets
Each preset must be added to the
presets
array in the configuration. -
Start using Twind in your components
Start using Twind classes to style your content.