This will be a web sms viewer app, an android phone will send sms data to this webapp and the webapp will store it so it can be viewed from anywhere. Make the app simple with function based views for now. The android app is ready, no need for any concern there.
On the root url, for example https://smsapi.tanjimreza.com.bd the android app will send post request with the json data. The data will then be saved in the database.
On the same url, the dashboard for messages will be shown.
There will be one page for now, the dashboard
The dashboard page will show all the messages sorted by time, there will be all available filters and a date filter to choose messages of a day or some day period.
The dashboard will have to be mobile responsive.
I'll create a simple web SMS viewer app using Next.js with function-based components. We'll use a SQLite database for storing the messages, and implement a dashboard with filtering capabilities. Let's break this down into steps:
Let's start by setting up the project structure and implementing the necessary components:
This implementation creates a simple web SMS viewer app with the following features:
/api/sms
) that handles POST requests from the Android app to store SMS data in the database.To use this app:
npm run dev
.https://your-domain.com/api/sms
with the SMS data.https://your-domain.com
and use the date filter to narrow down the displayed messages.The app uses Server Components for data fetching and Client Components for interactivity, providing a good balance between performance and user experience. The design is responsive and will work well on both desktop and mobile devices.
I understand that you're encountering an error related to a missing connection string for Vercel Postgres. Let's address this issue by properly setting up the database connection.
To resolve this error, we need to properly set up the Vercel Postgres connection string. Here's how we can modify our code:
These changes should address the connection string error and improve error handling throughout the application. Here's a summary of what we've done:
db.ts
file to use the postgres()
function, which automatically uses the connection string from environment variables.useMessages
hook to handle and display error messages more effectively.To complete the setup, you need to add the Vercel Postgres connection string to your environment variables. You can do this in your Vercel project settings or by adding a .env.local
file to your project root with the following content:
POSTGRES_URL="your_connection_string_here"
Make sure to replace "your_connection_string_here" with the actual connection string provided by Vercel for your Postgres database.
If you're running the app locally, you'll need to set up this environment variable. When deploying to Vercel, make sure to add this environment variable in your project settings.
These changes should resolve the connection string error and allow your application to connect to the Vercel Postgres database successfully.