Getting Started with React Native
This is a development approach using the React Native-based Granite framework. It's a good fit for teams that need native-level UI/UX or want to create an experience that blends naturally with the Toss app.
We want to provide an experience consistent with the native UI of the Toss app.
We need complex animations or gesture handling.
We're a team with React Native development experience.
If you want to develop with WebView → Getting started with WebView
1. Create a project
Run the following command in the location where you want to create the app.
npm create granite-app@"^1"pnpm create granite-app@"^1"yarn create granite-app@"^1"1-1. Set the app name
Enter the app name in kebab-case format.
my-granite-app1-2. Choose tools
When creating a project, you can choose code quality tools.
prettier+eslint: Handles code formatting and linting, respectively. It supports flexible code quality management with detailed settings and a variety of plugins.biome: A fast, integrated formatting and linting tool based on Rust. It enables efficient work with simple settings.
1-3. Install dependencies
Move to the project folder, then install the dependencies.
[Watch video](../resources/tutorials/react-native/react-native-tutorial-scaffold.mp4)
2. Install the framework
To use the Apps in Toss SDK, @apps-in-toss/framework you need to install the package.
3. Edit the configuration file
ait init You can use the command to set up the basic environment needed for app development.
Select a framework.
App name (
appName) should be entered. Please enter the same name that was registered in the Apps in Toss console.
When initialization is complete, granite.config.ts a file will be created in the project root. appName, displayName, iconPlease update them to match the app information registered in the Apps in Toss console.
4. Install TDS
TDS(Toss Design System) React Native Using the package makes it easy to apply components based on the Toss Design System.
For how to use TDS components and guides, TDS React Native documentationplease check it.
5. Run the development server
Once the Metro development server is running, you can view the mini app in the Sandbox app. For detailed instructions on testing in the Sandbox app, Sandbox app please check the documentation.
6. Run the mini app
Run on an iOS simulator
Run the Sandbox app.
Enter the scheme and press the "Open Scheme" button. Example:
intoss://kingtossAt the top of the screen,
Bundling {n}%...If it appears, the connection was successful.
[Watch video](../resources/development/local-server/rn-local-develop-ios-sim-example.mp4)
Run on a physical iOS device
To run on an iPhone, it must be connected to the same Wi-Fi as the local server.
When you run the Sandbox app, "Local Network" a permission request message appears. "Allow" please press the button.
On the server address input screen, enter the local server IP address and save it.
On macOS,
ipconfig getifaddr en0you can check the IP address with this command.
Press the "Open Scheme" button.
At the top of the screen,
Bundling {n}%...If it appears, the connection was successful.
Watch video
Run on an Android physical device or emulator
Connect the Android physical device to your computer with a USB cable.
adbconnect the port with the command.To connect a specific device,
-sadd the option.In the Sandbox app, enter the scheme and press the Run button. Example:
intoss://kingtossWhen the bundling progress status appears at the top of the screen, the connection is complete.
[Watch video](../resources/development/local-server/rn-local-develop-android-example.mp4)
7. Debugging
Preparation
React Native Debugger requires the Chrome browser. If it's not installed, Chrome web browserplease download it first.
Debugging with the Metro development server
With the development server running, j pressing the key in the terminal opens React Native Debugger. It only opens when the device and Metro server are connected.
The debugger provides the tabs below.
Console:
console.logYou can view logs recorded with these, and run code directly in the REPL environment.Source: You can view running code and add breakpoints.
Network: You can view network requests and responses.
Memory: You can profile Hermes engine memory usage.
Profiler: You can measure code execution performance.
Debugging with Breakpoints
To set a breakpoint, Cmd + Popen the file search window and select a file. Click the line you want to add a breakpoint to, and it will be added. When the code reaches that point, execution stops and you can check the current state.
In the source code, debugger if you add the keyword, the code will automatically stop at that point.
Debugging exception cases
Source tab you can enable the options below in the Breakpoints section at the top right.
Pause on uncaught exceptions: Automatically pauses code when an unexpected exception occurs.
Pause on caught exceptions: Pauses on all exceptions, regardless of whether they are handled.
Debugging with React DevTools
With React DevTools, you can visually explore component structure and debug it.
If the service is running, refresh the RN view in development mode with the R key. When a screen like the one below appears, the connection is complete.
Inspecting elements
After pressing the element selection button and touching the element you want to inspect on the device, React DevTools will jump directly to that element.
[Watch video](../resources/learn-more/debugging/inspecting.mp4)
Changing props
You can check the selected component's props and change them in real time. Double-click the prop you want, enter a value, and it will be applied immediately.
[Watch video](../resources/learn-more/debugging/changing-prop.mp4)
Troubleshooting
8. Build
A bundle file is .ait a file with the .ait extension, the packaged result of the built project.
When the build is complete, <service-name>.ait a file will be created in the project root. For detailed testing instructions, Toss app please refer to the documentation.
9. Release
For how to release, mini app release please refer to the documentation.