Strapi Tutorial - How to Configure Slug to have Nice URLs for SEO
Introduction In our previous posts, we have seen How to Create Article in Strapi…
May 11, 2021
We have a page, for example a Form
. And, upon submission we would want user to be redirected to some other page and pass some state or props so that that page can show some message or so.
withRouter
import { withRouter } from 'next/router'
withRouter
export default withRouter(EditUser);
Now in your component’s props, you have a router object.
I have a user edit form, and upon submission. I want user to be redirected to /user/<id>
And, I want to show a message that edit has been successful.
this.props.router.push({
pathname: `/users/${user.id}`,
query: {success: true}
});
Here, I’m passing a query parameter to that page. So it will be:
/users/1234?success=true
In my component jsx file, I want to show a bootstrap alert.
return (
<SimpleLayout>
{props.router.query.success &&
<div className="alert alert-success alert-dismissible fade show" role="alert">
Success.
<Button type="button" className="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</Button>
</div>
}
...
...
</SimpleLayout>
}
)
Note the props.router.query.success
Introduction In our previous posts, we have seen How to Create Article in Strapi…
Introduction I was trying to upload images to my backend using rest APIs. I was…
Introduction In this post, we will do following: create a Next.js project…
Introduction Next-auth is a fantastic library for abstracting handling of…
Introduction In this post, we will use in Next.js with strapi. And, we will…
Introduction This post is in contuation of our previous post: How to use Draft…
Introduction In this post we will see following: How to schedule a job on cron…
Introduction There are some cases, where I need another git repository while…
Introduction In this post, we will see how to fetch multiple credentials and…
Introduction I have an automation script, that I want to run on different…
Introduction I had to write a CICD system for one of our project. I had to…
Introduction Java log4j has many ways to initialize and append the desired…