Skip to content

nordhealth/react-example-project

Repository files navigation

react-example-project

This repo is an example of using React with Vite along with Nord Design System's components. TypeScript is used, but this is not a necessity for using React and Nord together.

This repo can be forked as a starting point for new apps. However, you may wish to undertake the process yourself so that all dependencies are up to date, and you can choose which tools you would like to use. The steps to integrate React and Nord are described next.

Setting up a project from scratch

First initialize a new Vite project with React:

npm create vite@latest [project-name] -- --template react

Or if you would like to start with TypeScript:

npm create vite@latest [project-name] -- --template react-ts

Follow any instructions printed in the terminal.

Next install Nord dependencies:

npm install @nordhealth/react @nordhealth/css --save

When complete, open your editor and navigate to main.jsx or main.tsx, and import the Nord dependencies:

// main.jsx
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.tsx'

import '@nordhealth/css';
import '@nordhealth/components';

createRoot(document.getElementById('root')!).render(
  <StrictMode>
    <App />
  </StrictMode>,
)

This will ensure Nord styles are included in your app, and register all Web Components ready for use.

To get types and IntelliSense for Nord components in JSX, add the following to your tsconfig.json in a TypeScript project, or jsconfig.json in a JavaScript project:

{
  "compilerOptions": {
    "types": ["@nordhealth/components/lib/react.d.ts"]
  }
}

Now everything is ready! In a component file, you can start using Nord:

import { useState } from "react";

function Example() {
  const [name, setName] = useState("");
  const [count, setCount] = useState(0);

  function handleNameChange(e) {
    setName(e.target.value);
  }

  function increment() {
    setCount(count + 1);
  }

  return (
    <>
      <nord-input label="Your name" value={name} onInput={handleNameChange}></nord-input>
      <p>{name}</p>

      <nord-button variant="primary" onClick={increment}>
        Count: {count}
      </nord-button>
    </>
  );
}

export default Example

Customize configuration

See Vite Configuration Reference.

Project Setup

Clone this repo, then:

npm install

Compile and Hot-Reload for Development

npm run dev

Type-Check, Compile and Minify for Production

npm run build

Can I use Nord in my own project?

Nord Design System is solely meant for building digital products and experiences for Nordhealth. Please see LICENSE for full license details.

Getting support

If you experience any issues while getting started with any of Nord’s tools, please head over to the Support page for more guidelines and help.

Copyright

Copyright © 2025 Nordhealth Ltd.

About

An example of consuming Nord Design System in a React project.

Resources

License

Stars

Watchers

Forks

Contributors